<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<title>API: datasource   DataSource.js  (YUI Library)</title>

	<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css" />
	<link rel="stylesheet" type="text/css" href="assets/api.css" />

    <script type="text/javascript" src="assets/api-js"></script>
    <script type="text/javascript" src="assets/ac-js"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">
	<div id="hd">
        <h1><a href="http://developer.yahoo.com/yui/" title="Yahoo! UI Library">Yahoo! UI Library</a></h1>
        <h3>DataSource Utility&nbsp; <span class="subtitle">2.9.0</span></h3>
        <a href="./index.html" title="Yahoo! UI Library">Yahoo! UI Library</a> 
            &gt; <a href="./module_datasource.html" title="datasource">datasource</a>
                
                 &gt; DataSource.js (source view) 
        <form onsubmit="return false">
            <div id="propertysearch">
                Search: <input autocomplete="off" id="searchinput" />
                <div id="searchresults">
                    &nbsp;
                </div>
            </div>
        </form>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
                <fieldset>
                    <legend>Filters</legend>
                <span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
                <span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
                <span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
                </fieldset>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 .classopts { display:none; }
                        </style>
                        <div class="highlight"><pre><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>

<span class="kd">var</span> <span class="nx">lang</span>   <span class="o">=</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">,</span>
    <span class="nx">util</span>   <span class="o">=</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">util</span><span class="p">,</span>
    <span class="nx">Ev</span>     <span class="o">=</span> <span class="nx">util</span><span class="p">.</span><span class="nx">Event</span><span class="p">;</span>

<span class="cm">/**</span>
<span class="cm"> * The DataSource utility provides a common configurable interface for widgets to</span>
<span class="cm"> * access a variety of data, from JavaScript arrays to online database servers.</span>
<span class="cm"> *</span>
<span class="cm"> * @module datasource</span>
<span class="cm"> * @requires yahoo, event</span>
<span class="cm"> * @optional json, get, connection </span>
<span class="cm"> * @title DataSource Utility</span>
<span class="cm"> */</span>

<span class="cm">/****************************************************************************/</span>
<span class="cm">/****************************************************************************/</span>
<span class="cm">/****************************************************************************/</span>

<span class="cm">/**</span>
<span class="cm"> * Base class for the YUI DataSource utility.</span>
<span class="cm"> *</span>
<span class="cm"> * @namespace YAHOO.util</span>
<span class="cm"> * @class YAHOO.util.DataSourceBase</span>
<span class="cm"> * @constructor</span>
<span class="cm"> * @param oLiveData {HTMLElement}  Pointer to live data.</span>
<span class="cm"> * @param oConfigs {object} (optional) Object literal of configuration values.</span>
<span class="cm"> */</span>
<span class="nx">util</span><span class="p">.</span><span class="nx">DataSourceBase</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">oLiveData</span> <span class="o">===</span> <span class="kc">null</span> <span class="o">||</span> <span class="nx">oLiveData</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Could not instantiate DataSource due to invalid live database&quot;</span><span class="p">,</span>
                <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="k">return</span><span class="p">;</span>
    <span class="p">}</span>
    
    <span class="k">this</span><span class="p">.</span><span class="nx">liveData</span> <span class="o">=</span> <span class="nx">oLiveData</span><span class="p">;</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">_oQueue</span> <span class="o">=</span> <span class="p">{</span><span class="nx">interval</span><span class="o">:</span><span class="kc">null</span><span class="p">,</span> <span class="nx">conn</span><span class="o">:</span><span class="kc">null</span><span class="p">,</span> <span class="nx">requests</span><span class="o">:</span><span class="p">[]};</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span> <span class="o">=</span> <span class="p">{};</span>   

    <span class="c1">// Set any config params passed in to override defaults</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">oConfigs</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">oConfigs</span><span class="p">.</span><span class="nx">constructor</span> <span class="o">==</span> <span class="nb">Object</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">sConfig</span> <span class="k">in</span> <span class="nx">oConfigs</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">sConfig</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">this</span><span class="p">[</span><span class="nx">sConfig</span><span class="p">]</span> <span class="o">=</span> <span class="nx">oConfigs</span><span class="p">[</span><span class="nx">sConfig</span><span class="p">];</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">}</span>
    
    <span class="c1">// Validate and initialize public configs</span>
    <span class="kd">var</span> <span class="nx">maxCacheEntries</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">maxCacheEntries</span><span class="p">;</span>
    <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isNumber</span><span class="p">(</span><span class="nx">maxCacheEntries</span><span class="p">)</span> <span class="o">||</span> <span class="p">(</span><span class="nx">maxCacheEntries</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">))</span> <span class="p">{</span>
        <span class="nx">maxCacheEntries</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="c1">// Initialize interval tracker</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">_aIntervals</span> <span class="o">=</span> <span class="p">[];</span>

    <span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
    <span class="c1">//</span>
    <span class="c1">// Custom Events</span>
    <span class="c1">//</span>
    <span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

    <span class="cm">/**</span>
<span class="cm">     * Fired when a request is made to the local cache.</span>
<span class="cm">     *</span>
<span class="cm">     * @event cacheRequestEvent</span>
<span class="cm">     * @param oArgs.request {Object} The request object.</span>
<span class="cm">     * @param oArgs.callback {Object} The callback object.</span>
<span class="cm">     * @param oArgs.caller {Object} (deprecated) Use callback.scope.</span>
<span class="cm">     */</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">createEvent</span><span class="p">(</span><span class="s2">&quot;cacheRequestEvent&quot;</span><span class="p">);</span>

    <span class="cm">/**</span>
<span class="cm">     * Fired when data is retrieved from the local cache.</span>
<span class="cm">     *</span>
<span class="cm">     * @event cacheResponseEvent</span>
<span class="cm">     * @param oArgs.request {Object} The request object.</span>
<span class="cm">     * @param oArgs.response {Object} The response object.</span>
<span class="cm">     * @param oArgs.callback {Object} The callback object.</span>
<span class="cm">     * @param oArgs.caller {Object} (deprecated) Use callback.scope.</span>
<span class="cm">     */</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">createEvent</span><span class="p">(</span><span class="s2">&quot;cacheResponseEvent&quot;</span><span class="p">);</span>

    <span class="cm">/**</span>
<span class="cm">     * Fired when a request is sent to the live data source.</span>
<span class="cm">     *</span>
<span class="cm">     * @event requestEvent</span>
<span class="cm">     * @param oArgs.request {Object} The request object.</span>
<span class="cm">     * @param oArgs.callback {Object} The callback object.</span>
<span class="cm">     * @param oArgs.tId {Number} Transaction ID.     </span>
<span class="cm">     * @param oArgs.caller {Object} (deprecated) Use callback.scope.</span>
<span class="cm">     */</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">createEvent</span><span class="p">(</span><span class="s2">&quot;requestEvent&quot;</span><span class="p">);</span>

    <span class="cm">/**</span>
<span class="cm">     * Fired when live data source sends response.</span>
<span class="cm">     *</span>
<span class="cm">     * @event responseEvent</span>
<span class="cm">     * @param oArgs.request {Object} The request object.</span>
<span class="cm">     * @param oArgs.response {Object} The raw response object.</span>
<span class="cm">     * @param oArgs.callback {Object} The callback object.</span>
<span class="cm">     * @param oArgs.tId {Number} Transaction ID.     </span>
<span class="cm">     * @param oArgs.caller {Object} (deprecated) Use callback.scope.</span>
<span class="cm">     */</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">createEvent</span><span class="p">(</span><span class="s2">&quot;responseEvent&quot;</span><span class="p">);</span>

    <span class="cm">/**</span>
<span class="cm">     * Fired when response is parsed.</span>
<span class="cm">     *</span>
<span class="cm">     * @event responseParseEvent</span>
<span class="cm">     * @param oArgs.request {Object} The request object.</span>
<span class="cm">     * @param oArgs.response {Object} The parsed response object.</span>
<span class="cm">     * @param oArgs.callback {Object} The callback object.</span>
<span class="cm">     * @param oArgs.caller {Object} (deprecated) Use callback.scope.</span>
<span class="cm">     */</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">createEvent</span><span class="p">(</span><span class="s2">&quot;responseParseEvent&quot;</span><span class="p">);</span>

    <span class="cm">/**</span>
<span class="cm">     * Fired when response is cached.</span>
<span class="cm">     *</span>
<span class="cm">     * @event responseCacheEvent</span>
<span class="cm">     * @param oArgs.request {Object} The request object.</span>
<span class="cm">     * @param oArgs.response {Object} The parsed response object.</span>
<span class="cm">     * @param oArgs.callback {Object} The callback object.</span>
<span class="cm">     * @param oArgs.caller {Object} (deprecated) Use callback.scope.</span>
<span class="cm">     */</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">createEvent</span><span class="p">(</span><span class="s2">&quot;responseCacheEvent&quot;</span><span class="p">);</span>
    <span class="cm">/**</span>
<span class="cm">     * Fired when an error is encountered with the live data source.</span>
<span class="cm">     *</span>
<span class="cm">     * @event dataErrorEvent</span>
<span class="cm">     * @param oArgs.request {Object} The request object.</span>
<span class="cm">     * @param oArgs.response {String} The response object (if available).</span>
<span class="cm">     * @param oArgs.callback {Object} The callback object.</span>
<span class="cm">     * @param oArgs.caller {Object} (deprecated) Use callback.scope.</span>
<span class="cm">     * @param oArgs.message {String} The error message.</span>
<span class="cm">     */</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">createEvent</span><span class="p">(</span><span class="s2">&quot;dataErrorEvent&quot;</span><span class="p">);</span>

    <span class="cm">/**</span>
<span class="cm">     * Fired when the local cache is flushed.</span>
<span class="cm">     *</span>
<span class="cm">     * @event cacheFlushEvent</span>
<span class="cm">     */</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">createEvent</span><span class="p">(</span><span class="s2">&quot;cacheFlushEvent&quot;</span><span class="p">);</span>

    <span class="kd">var</span> <span class="nx">DS</span> <span class="o">=</span> <span class="nx">util</span><span class="p">.</span><span class="nx">DataSourceBase</span><span class="p">;</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">_sName</span> <span class="o">=</span> <span class="s2">&quot;DataSource instance&quot;</span> <span class="o">+</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">_nIndex</span><span class="p">;</span>
    <span class="nx">DS</span><span class="p">.</span><span class="nx">_nIndex</span><span class="o">++</span><span class="p">;</span>
    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;DataSource initialized&quot;</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
<span class="p">};</span>

<span class="kd">var</span> <span class="nx">DS</span> <span class="o">=</span> <span class="nx">util</span><span class="p">.</span><span class="nx">DataSourceBase</span><span class="p">;</span>

<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">DS</span><span class="p">,</span> <span class="p">{</span>

<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// DataSourceBase public constants</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

<span class="cm">/**</span>
<span class="cm"> * Type is unknown.</span>
<span class="cm"> *</span>
<span class="cm"> * @property TYPE_UNKNOWN</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @final</span>
<span class="cm"> * @default -1</span>
<span class="cm"> */</span>
<span class="nx">TYPE_UNKNOWN</span> <span class="o">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Type is a JavaScript Array.</span>
<span class="cm"> *</span>
<span class="cm"> * @property TYPE_JSARRAY</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @final</span>
<span class="cm"> * @default 0</span>
<span class="cm"> */</span>
<span class="nx">TYPE_JSARRAY</span> <span class="o">:</span> <span class="mi">0</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Type is a JavaScript Function.</span>
<span class="cm"> *</span>
<span class="cm"> * @property TYPE_JSFUNCTION</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @final</span>
<span class="cm"> * @default 1</span>
<span class="cm"> */</span>
<span class="nx">TYPE_JSFUNCTION</span> <span class="o">:</span> <span class="mi">1</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Type is hosted on a server via an XHR connection.</span>
<span class="cm"> *</span>
<span class="cm"> * @property TYPE_XHR</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @final</span>
<span class="cm"> * @default 2</span>
<span class="cm"> */</span>
<span class="nx">TYPE_XHR</span> <span class="o">:</span> <span class="mi">2</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Type is JSON.</span>
<span class="cm"> *</span>
<span class="cm"> * @property TYPE_JSON</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @final</span>
<span class="cm"> * @default 3</span>
<span class="cm"> */</span>
<span class="nx">TYPE_JSON</span> <span class="o">:</span> <span class="mi">3</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Type is XML.</span>
<span class="cm"> *</span>
<span class="cm"> * @property TYPE_XML</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @final</span>
<span class="cm"> * @default 4</span>
<span class="cm"> */</span>
<span class="nx">TYPE_XML</span> <span class="o">:</span> <span class="mi">4</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Type is plain text.</span>
<span class="cm"> *</span>
<span class="cm"> * @property TYPE_TEXT</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @final</span>
<span class="cm"> * @default 5</span>
<span class="cm"> */</span>
<span class="nx">TYPE_TEXT</span> <span class="o">:</span> <span class="mi">5</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Type is an HTML TABLE element. Data is parsed out of TR elements from all TBODY elements.</span>
<span class="cm"> *</span>
<span class="cm"> * @property TYPE_HTMLTABLE</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @final</span>
<span class="cm"> * @default 6</span>
<span class="cm"> */</span>
<span class="nx">TYPE_HTMLTABLE</span> <span class="o">:</span> <span class="mi">6</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Type is hosted on a server via a dynamic script node.</span>
<span class="cm"> *</span>
<span class="cm"> * @property TYPE_SCRIPTNODE</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @final</span>
<span class="cm"> * @default 7</span>
<span class="cm"> */</span>
<span class="nx">TYPE_SCRIPTNODE</span> <span class="o">:</span> <span class="mi">7</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Type is local.</span>
<span class="cm"> *</span>
<span class="cm"> * @property TYPE_LOCAL</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @final</span>
<span class="cm"> * @default 8</span>
<span class="cm"> */</span>
<span class="nx">TYPE_LOCAL</span> <span class="o">:</span> <span class="mi">8</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Error message for invalid dataresponses.</span>
<span class="cm"> *</span>
<span class="cm"> * @property ERROR_DATAINVALID</span>
<span class="cm"> * @type String</span>
<span class="cm"> * @final</span>
<span class="cm"> * @default &quot;Invalid data&quot;</span>
<span class="cm"> */</span>
<span class="nx">ERROR_DATAINVALID</span> <span class="o">:</span> <span class="s2">&quot;Invalid data&quot;</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Error message for null data responses.</span>
<span class="cm"> *</span>
<span class="cm"> * @property ERROR_DATANULL</span>
<span class="cm"> * @type String</span>
<span class="cm"> * @final</span>
<span class="cm"> * @default &quot;Null data&quot;</span>
<span class="cm"> */</span>
<span class="nx">ERROR_DATANULL</span> <span class="o">:</span> <span class="s2">&quot;Null data&quot;</span><span class="p">,</span>

<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// DataSourceBase private static properties</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

<span class="cm">/**</span>
<span class="cm"> * Internal class variable to index multiple DataSource instances.</span>
<span class="cm"> *</span>
<span class="cm"> * @property DataSourceBase._nIndex</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @private</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">_nIndex</span> <span class="o">:</span> <span class="mi">0</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Internal class variable to assign unique transaction IDs.</span>
<span class="cm"> *</span>
<span class="cm"> * @property DataSourceBase._nTransactionId</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @private</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">_nTransactionId</span> <span class="o">:</span> <span class="mi">0</span><span class="p">,</span>

<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// DataSourceBase private static methods</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="cm">/**</span>
<span class="cm"> * Clones object literal or array of object literals.</span>
<span class="cm"> *</span>
<span class="cm"> * @method DataSourceBase._cloneObject</span>
<span class="cm"> * @param o {Object} Object.</span>
<span class="cm"> * @private</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">_cloneObject</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">o</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">return</span> <span class="nx">o</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="kd">var</span> <span class="nx">copy</span> <span class="o">=</span> <span class="p">{};</span>

    <span class="k">if</span><span class="p">(</span><span class="nb">Object</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">toString</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="o">===</span> <span class="s2">&quot;[object RegExp]&quot;</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">copy</span> <span class="o">=</span> <span class="nx">o</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isFunction</span><span class="p">(</span><span class="nx">o</span><span class="p">))</span> <span class="p">{</span>
        <span class="nx">copy</span> <span class="o">=</span> <span class="nx">o</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">o</span><span class="p">))</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">array</span> <span class="o">=</span> <span class="p">[];</span>
        <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span><span class="nx">len</span><span class="o">=</span><span class="nx">o</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="nx">i</span><span class="o">&lt;</span><span class="nx">len</span><span class="p">;</span><span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">array</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">_cloneObject</span><span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
        <span class="p">}</span>
        <span class="nx">copy</span> <span class="o">=</span> <span class="nx">array</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">o</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">x</span> <span class="k">in</span> <span class="nx">o</span><span class="p">){</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span> <span class="nx">x</span><span class="p">))</span> <span class="p">{</span>
                <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="nx">x</span><span class="p">])</span> <span class="o">&amp;&amp;</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="nx">x</span><span class="p">])</span> <span class="o">||</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="nx">x</span><span class="p">]))</span> <span class="p">{</span>
                    <span class="nx">copy</span><span class="p">[</span><span class="nx">x</span><span class="p">]</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">_cloneObject</span><span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="nx">x</span><span class="p">]);</span>
                <span class="p">}</span>
                <span class="k">else</span> <span class="p">{</span>
                    <span class="nx">copy</span><span class="p">[</span><span class="nx">x</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="p">[</span><span class="nx">x</span><span class="p">];</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nx">copy</span> <span class="o">=</span> <span class="nx">o</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="k">return</span> <span class="nx">copy</span><span class="p">;</span>
<span class="p">},</span>
    
<span class="cm">/**</span>
<span class="cm"> * Get an XPath-specified value for a given field from an XML node or document.</span>
<span class="cm"> *</span>
<span class="cm"> * @method _getLocationValue</span>
<span class="cm"> * @param field {String | Object} Field definition.</span>
<span class="cm"> * @param context {Object} XML node or document to search within.</span>
<span class="cm"> * @return {Object} Data value or null.</span>
<span class="cm"> * @static</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">_getLocationValue</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">field</span><span class="p">,</span> <span class="nx">context</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">locator</span> <span class="o">=</span> <span class="nx">field</span><span class="p">.</span><span class="nx">locator</span> <span class="o">||</span> <span class="nx">field</span><span class="p">.</span><span class="nx">key</span> <span class="o">||</span> <span class="nx">field</span><span class="p">,</span>
        <span class="nx">xmldoc</span> <span class="o">=</span> <span class="nx">context</span><span class="p">.</span><span class="nx">ownerDocument</span> <span class="o">||</span> <span class="nx">context</span><span class="p">,</span>
        <span class="nx">result</span><span class="p">,</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">value</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>

    <span class="k">try</span> <span class="p">{</span>
        <span class="c1">// Standards mode</span>
        <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isUndefined</span><span class="p">(</span><span class="nx">xmldoc</span><span class="p">.</span><span class="nx">evaluate</span><span class="p">))</span> <span class="p">{</span>
            <span class="nx">result</span> <span class="o">=</span> <span class="nx">xmldoc</span><span class="p">.</span><span class="nx">evaluate</span><span class="p">(</span><span class="nx">locator</span><span class="p">,</span> <span class="nx">context</span><span class="p">,</span> <span class="nx">xmldoc</span><span class="p">.</span><span class="nx">createNSResolver</span><span class="p">(</span><span class="o">!</span><span class="nx">context</span><span class="p">.</span><span class="nx">ownerDocument</span> <span class="o">?</span> <span class="nx">context</span><span class="p">.</span><span class="nx">documentElement</span> <span class="o">:</span> <span class="nx">context</span><span class="p">.</span><span class="nx">ownerDocument</span><span class="p">.</span><span class="nx">documentElement</span><span class="p">),</span> <span class="mi">0</span><span class="p">,</span> <span class="kc">null</span><span class="p">);</span>
            <span class="k">while</span><span class="p">(</span><span class="nx">res</span> <span class="o">=</span> <span class="nx">result</span><span class="p">.</span><span class="nx">iterateNext</span><span class="p">())</span> <span class="p">{</span>
                <span class="nx">value</span> <span class="o">=</span> <span class="nx">res</span><span class="p">.</span><span class="nx">textContent</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>
        <span class="c1">// IE mode</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="nx">xmldoc</span><span class="p">.</span><span class="nx">setProperty</span><span class="p">(</span><span class="s2">&quot;SelectionLanguage&quot;</span><span class="p">,</span> <span class="s2">&quot;XPath&quot;</span><span class="p">);</span>
            <span class="nx">result</span> <span class="o">=</span> <span class="nx">context</span><span class="p">.</span><span class="nx">selectNodes</span><span class="p">(</span><span class="nx">locator</span><span class="p">)[</span><span class="mi">0</span><span class="p">];</span>
            <span class="nx">value</span> <span class="o">=</span> <span class="nx">result</span><span class="p">.</span><span class="nx">value</span> <span class="o">||</span> <span class="nx">result</span><span class="p">.</span><span class="nx">text</span> <span class="o">||</span> <span class="kc">null</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="k">return</span> <span class="nx">value</span><span class="p">;</span>

    <span class="p">}</span>
    <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
    <span class="p">}</span>
<span class="p">},</span>

<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// DataSourceBase public static methods</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

<span class="cm">/**</span>
<span class="cm"> * Executes a configured callback.  For object literal callbacks, the third</span>
<span class="cm"> * param determines whether to execute the success handler or failure handler.</span>
<span class="cm"> *  </span>
<span class="cm"> * @method issueCallback</span>
<span class="cm"> * @param callback {Function|Object} the callback to execute</span>
<span class="cm"> * @param params {Array} params to be passed to the callback method</span>
<span class="cm"> * @param error {Boolean} whether an error occurred</span>
<span class="cm"> * @param scope {Object} the scope from which to execute the callback</span>
<span class="cm"> * (deprecated - use an object literal callback)</span>
<span class="cm"> * @static     </span>
<span class="cm"> */</span>
<span class="nx">issueCallback</span> <span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">callback</span><span class="p">,</span><span class="nx">params</span><span class="p">,</span><span class="nx">error</span><span class="p">,</span><span class="nx">scope</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isFunction</span><span class="p">(</span><span class="nx">callback</span><span class="p">))</span> <span class="p">{</span>
        <span class="nx">callback</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">scope</span><span class="p">,</span> <span class="nx">params</span><span class="p">);</span>
    <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">callback</span><span class="p">))</span> <span class="p">{</span>
        <span class="nx">scope</span> <span class="o">=</span> <span class="nx">callback</span><span class="p">.</span><span class="nx">scope</span> <span class="o">||</span> <span class="nx">scope</span> <span class="o">||</span> <span class="nb">window</span><span class="p">;</span>
        <span class="kd">var</span> <span class="nx">callbackFunc</span> <span class="o">=</span> <span class="nx">callback</span><span class="p">.</span><span class="nx">success</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">callbackFunc</span> <span class="o">=</span> <span class="nx">callback</span><span class="p">.</span><span class="nx">failure</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">callbackFunc</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">callbackFunc</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">scope</span><span class="p">,</span> <span class="nx">params</span><span class="p">.</span><span class="nx">concat</span><span class="p">([</span><span class="nx">callback</span><span class="p">.</span><span class="nx">argument</span><span class="p">]));</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Converts data to type String.</span>
<span class="cm"> *</span>
<span class="cm"> * @method DataSourceBase.parseString</span>
<span class="cm"> * @param oData {String | Number | Boolean | Date | Array | Object} Data to parse.</span>
<span class="cm"> * The special values null and undefined will return null.</span>
<span class="cm"> * @return {String} A string, or null.</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">parseString</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oData</span><span class="p">)</span> <span class="p">{</span>
    <span class="c1">// Special case null and undefined</span>
    <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">oData</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
    <span class="p">}</span>
    
    <span class="c1">//Convert to string</span>
    <span class="kd">var</span> <span class="nx">string</span> <span class="o">=</span> <span class="nx">oData</span> <span class="o">+</span> <span class="s2">&quot;&quot;</span><span class="p">;</span>

    <span class="c1">// Validate</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">string</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">return</span> <span class="nx">string</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Could not convert data &quot;</span> <span class="o">+</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oData</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; to type String&quot;</span><span class="p">,</span> <span class="s2">&quot;warn&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
    <span class="p">}</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Converts data to type Number.</span>
<span class="cm"> *</span>
<span class="cm"> * @method DataSourceBase.parseNumber</span>
<span class="cm"> * @param oData {String | Number | Boolean} Data to convert. Note, the following</span>
<span class="cm"> * values return as null: null, undefined, NaN, &quot;&quot;. </span>
<span class="cm"> * @return {Number} A number, or null.</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">parseNumber</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oData</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">oData</span><span class="p">)</span> <span class="o">||</span> <span class="p">(</span><span class="nx">oData</span> <span class="o">===</span> <span class="s2">&quot;&quot;</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="c1">//Convert to number</span>
    <span class="kd">var</span> <span class="nx">number</span> <span class="o">=</span> <span class="nx">oData</span> <span class="o">*</span> <span class="mi">1</span><span class="p">;</span>
    
    <span class="c1">// Validate</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isNumber</span><span class="p">(</span><span class="nx">number</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">return</span> <span class="nx">number</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Could not convert data &quot;</span> <span class="o">+</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oData</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; to type Number&quot;</span><span class="p">,</span> <span class="s2">&quot;warn&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
    <span class="p">}</span>
<span class="p">},</span>
<span class="c1">// Backward compatibility</span>
<span class="nx">convertNumber</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oData</span><span class="p">)</span> <span class="p">{</span>
    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;The method YAHOO.util.DataSourceBase.convertNumber() has been&quot;</span> <span class="o">+</span>
    <span class="s2">&quot; deprecated in favor of YAHOO.util.DataSourceBase.parseNumber()&quot;</span><span class="p">,</span> <span class="s2">&quot;warn&quot;</span><span class="p">,</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="k">return</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">parseNumber</span><span class="p">(</span><span class="nx">oData</span><span class="p">);</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Converts data to type Date.</span>
<span class="cm"> *</span>
<span class="cm"> * @method DataSourceBase.parseDate</span>
<span class="cm"> * @param oData {Date | String | Number} Data to convert.</span>
<span class="cm"> * @return {Date} A Date instance.</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">parseDate</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oData</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">date</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
    
    <span class="c1">//Convert to date</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">oData</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="p">(</span><span class="nx">oData</span> <span class="k">instanceof</span> <span class="nb">Date</span><span class="p">))</span> <span class="p">{</span>
        <span class="nx">date</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">(</span><span class="nx">oData</span><span class="p">);</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="k">return</span> <span class="nx">oData</span><span class="p">;</span>
    <span class="p">}</span>
    
    <span class="c1">// Validate</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">date</span> <span class="k">instanceof</span> <span class="nb">Date</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">return</span> <span class="nx">date</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Could not convert data &quot;</span> <span class="o">+</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oData</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; to type Date&quot;</span><span class="p">,</span> <span class="s2">&quot;warn&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
    <span class="p">}</span>
<span class="p">},</span>
<span class="c1">// Backward compatibility</span>
<span class="nx">convertDate</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oData</span><span class="p">)</span> <span class="p">{</span>
    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;The method YAHOO.util.DataSourceBase.convertDate() has been&quot;</span> <span class="o">+</span>
    <span class="s2">&quot; deprecated in favor of YAHOO.util.DataSourceBase.parseDate()&quot;</span><span class="p">,</span> <span class="s2">&quot;warn&quot;</span><span class="p">,</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="k">return</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">parseDate</span><span class="p">(</span><span class="nx">oData</span><span class="p">);</span>
<span class="p">}</span>

<span class="p">});</span>

<span class="c1">// Done in separate step so referenced functions are defined.</span>
<span class="cm">/**</span>
<span class="cm"> * Data parsing functions.</span>
<span class="cm"> * @property DataSource.Parser</span>
<span class="cm"> * @type Object</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">DS</span><span class="p">.</span><span class="nx">Parser</span> <span class="o">=</span> <span class="p">{</span>
    <span class="nx">string</span>   <span class="o">:</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">parseString</span><span class="p">,</span>
    <span class="nx">number</span>   <span class="o">:</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">parseNumber</span><span class="p">,</span>
    <span class="nx">date</span>     <span class="o">:</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">parseDate</span>
<span class="p">};</span>

<span class="c1">// Prototype properties and methods</span>
<span class="nx">DS</span><span class="p">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="p">{</span>

<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// DataSourceBase private properties</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

<span class="cm">/**</span>
<span class="cm"> * Name of DataSource instance.</span>
<span class="cm"> *</span>
<span class="cm"> * @property _sName</span>
<span class="cm"> * @type String</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">_sName</span> <span class="o">:</span> <span class="kc">null</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Local cache of data result object literals indexed chronologically.</span>
<span class="cm"> *</span>
<span class="cm"> * @property _aCache</span>
<span class="cm"> * @type Object[]</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">_aCache</span> <span class="o">:</span> <span class="kc">null</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Local queue of request connections, enabled if queue needs to be managed.</span>
<span class="cm"> *</span>
<span class="cm"> * @property _oQueue</span>
<span class="cm"> * @type Object</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">_oQueue</span> <span class="o">:</span> <span class="kc">null</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Array of polling interval IDs that have been enabled, needed to clear all intervals.</span>
<span class="cm"> *</span>
<span class="cm"> * @property _aIntervals</span>
<span class="cm"> * @type Array</span>
<span class="cm"> * @private</span>
<span class="cm"> */</span>
<span class="nx">_aIntervals</span> <span class="o">:</span> <span class="kc">null</span><span class="p">,</span>

<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// DataSourceBase public properties</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

<span class="cm">/**</span>
<span class="cm"> * Max size of the local cache.  Set to 0 to turn off caching.  Caching is</span>
<span class="cm"> * useful to reduce the number of server connections.  Recommended only for data</span>
<span class="cm"> * sources that return comprehensive results for queries or when stale data is</span>
<span class="cm"> * not an issue.</span>
<span class="cm"> *</span>
<span class="cm"> * @property maxCacheEntries</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @default 0</span>
<span class="cm"> */</span>
<span class="nx">maxCacheEntries</span> <span class="o">:</span> <span class="mi">0</span><span class="p">,</span>

 <span class="cm">/**</span>
<span class="cm"> * Pointer to live database.</span>
<span class="cm"> *</span>
<span class="cm"> * @property liveData</span>
<span class="cm"> * @type Object</span>
<span class="cm"> */</span>
<span class="nx">liveData</span> <span class="o">:</span> <span class="kc">null</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Where the live data is held:</span>
<span class="cm"> * </span>
<span class="cm"> * &lt;dl&gt;  </span>
<span class="cm"> *    &lt;dt&gt;TYPE_UNKNOWN&lt;/dt&gt;</span>
<span class="cm"> *    &lt;dt&gt;TYPE_LOCAL&lt;/dt&gt;</span>
<span class="cm"> *    &lt;dt&gt;TYPE_XHR&lt;/dt&gt;</span>
<span class="cm"> *    &lt;dt&gt;TYPE_SCRIPTNODE&lt;/dt&gt;</span>
<span class="cm"> *    &lt;dt&gt;TYPE_JSFUNCTION&lt;/dt&gt;</span>
<span class="cm"> * &lt;/dl&gt; </span>
<span class="cm"> *  </span>
<span class="cm"> * @property dataType</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @default YAHOO.util.DataSourceBase.TYPE_UNKNOWN</span>
<span class="cm"> *</span>
<span class="cm"> */</span>
<span class="nx">dataType</span> <span class="o">:</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_UNKNOWN</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Format of response:</span>
<span class="cm"> *  </span>
<span class="cm"> * &lt;dl&gt;  </span>
<span class="cm"> *    &lt;dt&gt;TYPE_UNKNOWN&lt;/dt&gt;</span>
<span class="cm"> *    &lt;dt&gt;TYPE_JSARRAY&lt;/dt&gt;</span>
<span class="cm"> *    &lt;dt&gt;TYPE_JSON&lt;/dt&gt;</span>
<span class="cm"> *    &lt;dt&gt;TYPE_XML&lt;/dt&gt;</span>
<span class="cm"> *    &lt;dt&gt;TYPE_TEXT&lt;/dt&gt;</span>
<span class="cm"> *    &lt;dt&gt;TYPE_HTMLTABLE&lt;/dt&gt; </span>
<span class="cm"> * &lt;/dl&gt; </span>
<span class="cm"> *</span>
<span class="cm"> * @property responseType</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @default YAHOO.util.DataSourceBase.TYPE_UNKNOWN</span>
<span class="cm"> */</span>
<span class="nx">responseType</span> <span class="o">:</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_UNKNOWN</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Response schema object literal takes a combination of the following properties:</span>
<span class="cm"> *</span>
<span class="cm"> * &lt;dl&gt;</span>
<span class="cm"> * &lt;dt&gt;resultsList&lt;/dt&gt; &lt;dd&gt;Pointer to array of tabular data&lt;/dd&gt;</span>
<span class="cm"> * &lt;dt&gt;resultNode&lt;/dt&gt; &lt;dd&gt;Pointer to node name of row data (XML data only)&lt;/dd&gt;</span>
<span class="cm"> * &lt;dt&gt;recordDelim&lt;/dt&gt; &lt;dd&gt;Record delimiter (text data only)&lt;/dd&gt;</span>
<span class="cm"> * &lt;dt&gt;fieldDelim&lt;/dt&gt; &lt;dd&gt;Field delimiter (text data only)&lt;/dd&gt;</span>
<span class="cm"> * &lt;dt&gt;fields&lt;/dt&gt; &lt;dd&gt;Array of field names (aka keys), or array of object literals</span>
<span class="cm"> * such as: {key:&quot;fieldname&quot;,parser:YAHOO.util.DataSourceBase.parseDate}&lt;/dd&gt;</span>
<span class="cm"> * &lt;dt&gt;metaFields&lt;/dt&gt; &lt;dd&gt;Object literal of keys to include in the oParsedResponse.meta collection&lt;/dd&gt;</span>
<span class="cm"> * &lt;dt&gt;metaNode&lt;/dt&gt; &lt;dd&gt;Name of the node under which to search for meta information in XML response data&lt;/dd&gt;</span>
<span class="cm"> * &lt;/dl&gt;</span>
<span class="cm"> *</span>
<span class="cm"> * @property responseSchema</span>
<span class="cm"> * @type Object</span>
<span class="cm"> */</span>
<span class="nx">responseSchema</span> <span class="o">:</span> <span class="kc">null</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Additional arguments passed to the JSON parse routine.  The JSON string</span>
<span class="cm"> * is the assumed first argument (where applicable).  This property is not</span>
<span class="cm"> * set by default, but the parse methods will use it if present.</span>
<span class="cm"> *</span>
<span class="cm"> * @property parseJSONArgs</span>
<span class="cm"> * @type {MIXED|Array} If an Array, contents are used as individual arguments.</span>
<span class="cm"> *                     Otherwise, value is used as an additional argument.</span>
<span class="cm"> */</span>
<span class="c1">// property intentionally undefined</span>
 
<span class="cm">/**</span>
<span class="cm"> * When working with XML data, setting this property to true enables support for</span>
<span class="cm"> * XPath-syntaxed locators in schema definitions.</span>
<span class="cm"> *</span>
<span class="cm"> * @property useXPath</span>
<span class="cm"> * @type Boolean</span>
<span class="cm"> * @default false</span>
<span class="cm"> */</span>
<span class="nx">useXPath</span> <span class="o">:</span> <span class="kc">false</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Clones entries before adding to cache.</span>
<span class="cm"> *</span>
<span class="cm"> * @property cloneBeforeCaching</span>
<span class="cm"> * @type Boolean</span>
<span class="cm"> * @default false</span>
<span class="cm"> */</span>
<span class="nx">cloneBeforeCaching</span> <span class="o">:</span> <span class="kc">false</span><span class="p">,</span>

<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// DataSourceBase public methods</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

<span class="cm">/**</span>
<span class="cm"> * Public accessor to the unique name of the DataSource instance.</span>
<span class="cm"> *</span>
<span class="cm"> * @method toString</span>
<span class="cm"> * @return {String} Unique name of the DataSource instance.</span>
<span class="cm"> */</span>
<span class="nx">toString</span> <span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_sName</span><span class="p">;</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Overridable method passes request to cache and returns cached response if any,</span>
<span class="cm"> * refreshing the hit in the cache as the newest item. Returns null if there is</span>
<span class="cm"> * no cache hit.</span>
<span class="cm"> *</span>
<span class="cm"> * @method getCachedResponse</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oCallback {Object} Callback object.</span>
<span class="cm"> * @param oCaller {Object} (deprecated) Use callback object.</span>
<span class="cm"> * @return {Object} Cached response object or null.</span>
<span class="cm"> */</span>
<span class="nx">getCachedResponse</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">aCache</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_aCache</span><span class="p">;</span>

    <span class="c1">// If cache is enabled...</span>
    <span class="k">if</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">maxCacheEntries</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>        
        <span class="c1">// Initialize local cache</span>
        <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">aCache</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">_aCache</span> <span class="o">=</span> <span class="p">[];</span>
            <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Cache initialized&quot;</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="p">}</span>
        <span class="c1">// Look in local cache</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="kd">var</span> <span class="nx">nCacheLength</span> <span class="o">=</span> <span class="nx">aCache</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">nCacheLength</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
                <span class="kd">var</span> <span class="nx">oResponse</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;cacheRequestEvent&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span><span class="nx">callback</span><span class="o">:</span><span class="nx">oCallback</span><span class="p">,</span><span class="nx">caller</span><span class="o">:</span><span class="nx">oCaller</span><span class="p">});</span>
        
                <span class="c1">// Loop through each cached element</span>
                <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="nx">nCacheLength</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
                    <span class="kd">var</span> <span class="nx">oCacheElem</span> <span class="o">=</span> <span class="nx">aCache</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
        
                    <span class="c1">// Defer cache hit logic to a public overridable method</span>
                    <span class="k">if</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isCacheHit</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span><span class="nx">oCacheElem</span><span class="p">.</span><span class="nx">request</span><span class="p">))</span> <span class="p">{</span>
                        <span class="c1">// The cache returned a hit!</span>
                        <span class="c1">// Grab the cached response</span>
                        <span class="nx">oResponse</span> <span class="o">=</span> <span class="nx">oCacheElem</span><span class="p">.</span><span class="nx">response</span><span class="p">;</span>
                        <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;cacheResponseEvent&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span><span class="nx">response</span><span class="o">:</span><span class="nx">oResponse</span><span class="p">,</span><span class="nx">callback</span><span class="o">:</span><span class="nx">oCallback</span><span class="p">,</span><span class="nx">caller</span><span class="o">:</span><span class="nx">oCaller</span><span class="p">});</span>
                        
                        <span class="c1">// Refresh the position of the cache hit</span>
                        <span class="k">if</span><span class="p">(</span><span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">nCacheLength</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
                            <span class="c1">// Remove element from its original location</span>
                            <span class="nx">aCache</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span><span class="mi">1</span><span class="p">);</span>
                            <span class="c1">// Add as newest</span>
                            <span class="k">this</span><span class="p">.</span><span class="nx">addToCache</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oResponse</span><span class="p">);</span>
                            <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Refreshed cache position of the response for \&quot;&quot;</span> <span class="o">+</span>  <span class="nx">oRequest</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
                        <span class="p">}</span>
                        
                        <span class="c1">// Add a cache flag</span>
                        <span class="nx">oResponse</span><span class="p">.</span><span class="nx">cached</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                        <span class="k">break</span><span class="p">;</span>
                    <span class="p">}</span>
                <span class="p">}</span>
                <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;The cached response for \&quot;&quot;</span> <span class="o">+</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">)</span> <span class="o">+</span>
                        <span class="s2">&quot;\&quot; is &quot;</span> <span class="o">+</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oResponse</span><span class="p">),</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
                <span class="k">return</span> <span class="nx">oResponse</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">aCache</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">_aCache</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Cache destroyed&quot;</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="p">}</span>
    <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Default overridable method matches given request to given cached request.</span>
<span class="cm"> * Returns true if is a hit, returns false otherwise.  Implementers should</span>
<span class="cm"> * override this method to customize the cache-matching algorithm.</span>
<span class="cm"> *</span>
<span class="cm"> * @method isCacheHit</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oCachedRequest {Object} Cached request object.</span>
<span class="cm"> * @return {Boolean} True if given request matches cached request, false otherwise.</span>
<span class="cm"> */</span>
<span class="nx">isCacheHit</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oCachedRequest</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">return</span> <span class="p">(</span><span class="nx">oRequest</span> <span class="o">===</span> <span class="nx">oCachedRequest</span><span class="p">);</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Adds a new item to the cache. If cache is full, evicts the stalest item</span>
<span class="cm"> * before adding the new item.</span>
<span class="cm"> *</span>
<span class="cm"> * @method addToCache</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oResponse {Object} Response object to cache.</span>
<span class="cm"> */</span>
<span class="nx">addToCache</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oResponse</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">aCache</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_aCache</span><span class="p">;</span>
    <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">aCache</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">return</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="c1">// If the cache is full, make room by removing stalest element (index=0)</span>
    <span class="k">while</span><span class="p">(</span><span class="nx">aCache</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;=</span> <span class="k">this</span><span class="p">.</span><span class="nx">maxCacheEntries</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">aCache</span><span class="p">.</span><span class="nx">shift</span><span class="p">();</span>
    <span class="p">}</span>

    <span class="c1">// Add to cache in the newest position, at the end of the array</span>
    <span class="nx">oResponse</span> <span class="o">=</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">cloneBeforeCaching</span><span class="p">)</span> <span class="o">?</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">_cloneObject</span><span class="p">(</span><span class="nx">oResponse</span><span class="p">)</span> <span class="o">:</span> <span class="nx">oResponse</span><span class="p">;</span>
    <span class="kd">var</span> <span class="nx">oCacheElem</span> <span class="o">=</span> <span class="p">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span><span class="nx">response</span><span class="o">:</span><span class="nx">oResponse</span><span class="p">};</span>
    <span class="nx">aCache</span><span class="p">[</span><span class="nx">aCache</span><span class="p">.</span><span class="nx">length</span><span class="p">]</span> <span class="o">=</span> <span class="nx">oCacheElem</span><span class="p">;</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;responseCacheEvent&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span><span class="nx">response</span><span class="o">:</span><span class="nx">oResponse</span><span class="p">});</span>
    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Cached the response for \&quot;&quot;</span> <span class="o">+</span>  <span class="nx">oRequest</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Flushes cache.</span>
<span class="cm"> *</span>
<span class="cm"> * @method flushCache</span>
<span class="cm"> */</span>
<span class="nx">flushCache</span> <span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
    <span class="k">if</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_aCache</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">_aCache</span> <span class="o">=</span> <span class="p">[];</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;cacheFlushEvent&quot;</span><span class="p">);</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Flushed the cache&quot;</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="p">}</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Sets up a polling mechanism to send requests at set intervals and forward</span>
<span class="cm"> * responses to given callback.</span>
<span class="cm"> *</span>
<span class="cm"> * @method setInterval</span>
<span class="cm"> * @param nMsec {Number} Length of interval in milliseconds.</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oCallback {Function} Handler function to receive the response.</span>
<span class="cm"> * @param oCaller {Object} (deprecated) Use oCallback.scope.</span>
<span class="cm"> * @return {Number} Interval ID.</span>
<span class="cm"> */</span>
<span class="nx">setInterval</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nMsec</span><span class="p">,</span> <span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isNumber</span><span class="p">(</span><span class="nx">nMsec</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">nMsec</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">))</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Enabling polling to live data for \&quot;&quot;</span> <span class="o">+</span> <span class="nx">oRequest</span> <span class="o">+</span> <span class="s2">&quot;\&quot; at interval &quot;</span> <span class="o">+</span> <span class="nx">nMsec</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="kd">var</span> <span class="nx">oSelf</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
        <span class="kd">var</span> <span class="nx">nId</span> <span class="o">=</span> <span class="nx">setInterval</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
            <span class="nx">oSelf</span><span class="p">.</span><span class="nx">makeConnection</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">);</span>
        <span class="p">},</span> <span class="nx">nMsec</span><span class="p">);</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">_aIntervals</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">nId</span><span class="p">);</span>
        <span class="k">return</span> <span class="nx">nId</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Could not enable polling to live data for \&quot;&quot;</span> <span class="o">+</span> <span class="nx">oRequest</span> <span class="o">+</span> <span class="s2">&quot;\&quot; at interval &quot;</span> <span class="o">+</span> <span class="nx">nMsec</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="p">}</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Disables polling mechanism associated with the given interval ID. Does not</span>
<span class="cm"> * affect transactions that are in progress.</span>
<span class="cm"> *</span>
<span class="cm"> * @method clearInterval</span>
<span class="cm"> * @param nId {Number} Interval ID.</span>
<span class="cm"> */</span>
<span class="nx">clearInterval</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nId</span><span class="p">)</span> <span class="p">{</span>
    <span class="c1">// Remove from tracker if there</span>
    <span class="kd">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_aIntervals</span> <span class="o">||</span> <span class="p">[];</span>
    <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="nx">tracker</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span><span class="o">&gt;-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">tracker</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="nx">nId</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">tracker</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span><span class="mi">1</span><span class="p">);</span>
            <span class="nx">clearInterval</span><span class="p">(</span><span class="nx">nId</span><span class="p">);</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Disables all known polling intervals. Does not affect transactions that are</span>
<span class="cm"> * in progress.</span>
<span class="cm"> *</span>
<span class="cm"> * @method clearAllIntervals</span>
<span class="cm"> */</span>
<span class="nx">clearAllIntervals</span> <span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_aIntervals</span> <span class="o">||</span> <span class="p">[];</span>
    <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="nx">tracker</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span><span class="o">&gt;-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">clearInterval</span><span class="p">(</span><span class="nx">tracker</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
    <span class="p">}</span>
    <span class="nx">tracker</span> <span class="o">=</span> <span class="p">[];</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * First looks for cached response, then sends request to live data. The</span>
<span class="cm"> * following arguments are passed to the callback function:</span>
<span class="cm"> *     &lt;dl&gt;</span>
<span class="cm"> *     &lt;dt&gt;&lt;code&gt;oRequest&lt;/code&gt;&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;The same value that was passed in as the first argument to sendRequest.&lt;/dd&gt;</span>
<span class="cm"> *     &lt;dt&gt;&lt;code&gt;oParsedResponse&lt;/code&gt;&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;An object literal containing the following properties:</span>
<span class="cm"> *         &lt;dl&gt;</span>
<span class="cm"> *         &lt;dt&gt;&lt;code&gt;tId&lt;/code&gt;&lt;/dt&gt;</span>
<span class="cm"> *         &lt;dd&gt;Unique transaction ID number.&lt;/dd&gt;</span>
<span class="cm"> *         &lt;dt&gt;&lt;code&gt;results&lt;/code&gt;&lt;/dt&gt;</span>
<span class="cm"> *         &lt;dd&gt;Schema-parsed data results.&lt;/dd&gt;</span>
<span class="cm"> *         &lt;dt&gt;&lt;code&gt;error&lt;/code&gt;&lt;/dt&gt;</span>
<span class="cm"> *         &lt;dd&gt;True in cases of data error.&lt;/dd&gt;</span>
<span class="cm"> *         &lt;dt&gt;&lt;code&gt;cached&lt;/code&gt;&lt;/dt&gt;</span>
<span class="cm"> *         &lt;dd&gt;True when response is returned from DataSource cache.&lt;/dd&gt; </span>
<span class="cm"> *         &lt;dt&gt;&lt;code&gt;meta&lt;/code&gt;&lt;/dt&gt;</span>
<span class="cm"> *         &lt;dd&gt;Schema-parsed meta data.&lt;/dd&gt;</span>
<span class="cm"> *         &lt;/dl&gt;</span>
<span class="cm"> *     &lt;dt&gt;&lt;code&gt;oPayload&lt;/code&gt;&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;The same value as was passed in as &lt;code&gt;argument&lt;/code&gt; in the oCallback object literal.&lt;/dd&gt;</span>
<span class="cm"> *     &lt;/dl&gt; </span>
<span class="cm"> *</span>
<span class="cm"> * @method sendRequest</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oCallback {Object} An object literal with the following properties:</span>
<span class="cm"> *     &lt;dl&gt;</span>
<span class="cm"> *     &lt;dt&gt;&lt;code&gt;success&lt;/code&gt;&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;The function to call when the data is ready.&lt;/dd&gt;</span>
<span class="cm"> *     &lt;dt&gt;&lt;code&gt;failure&lt;/code&gt;&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;The function to call upon a response failure condition.&lt;/dd&gt;</span>
<span class="cm"> *     &lt;dt&gt;&lt;code&gt;scope&lt;/code&gt;&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;The object to serve as the scope for the success and failure handlers.&lt;/dd&gt;</span>
<span class="cm"> *     &lt;dt&gt;&lt;code&gt;argument&lt;/code&gt;&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;Arbitrary data that will be passed back to the success and failure handlers.&lt;/dd&gt;</span>
<span class="cm"> *     &lt;/dl&gt; </span>
<span class="cm"> * @param oCaller {Object} (deprecated) Use oCallback.scope.</span>
<span class="cm"> * @return {Number} Transaction ID, or null if response found in cache.</span>
<span class="cm"> */</span>
<span class="nx">sendRequest</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">)</span> <span class="p">{</span>
    <span class="c1">// First look in cache</span>
    <span class="kd">var</span> <span class="nx">oCachedResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getCachedResponse</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">);</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">oCachedResponse</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">DS</span><span class="p">.</span><span class="nx">issueCallback</span><span class="p">(</span><span class="nx">oCallback</span><span class="p">,[</span><span class="nx">oRequest</span><span class="p">,</span><span class="nx">oCachedResponse</span><span class="p">],</span><span class="kc">false</span><span class="p">,</span><span class="nx">oCaller</span><span class="p">);</span>
        <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
    <span class="p">}</span>


    <span class="c1">// Not in cache, so forward request to live data</span>
    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Making connection to live data for \&quot;&quot;</span> <span class="o">+</span> <span class="nx">oRequest</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">makeConnection</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">);</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Overridable default method generates a unique transaction ID and passes </span>
<span class="cm"> * the live data reference directly to the  handleResponse function. This</span>
<span class="cm"> * method should be implemented by subclasses to achieve more complex behavior</span>
<span class="cm"> * or to access remote data.          </span>
<span class="cm"> *</span>
<span class="cm"> * @method makeConnection</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oCallback {Object} Callback object literal.</span>
<span class="cm"> * @param oCaller {Object} (deprecated) Use oCallback.scope.</span>
<span class="cm"> * @return {Number} Transaction ID.</span>
<span class="cm"> */</span>
<span class="nx">makeConnection</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">tId</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">_nTransactionId</span><span class="o">++</span><span class="p">;</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;requestEvent&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">tId</span><span class="o">:</span><span class="nx">tId</span><span class="p">,</span> <span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span><span class="nx">callback</span><span class="o">:</span><span class="nx">oCallback</span><span class="p">,</span><span class="nx">caller</span><span class="o">:</span><span class="nx">oCaller</span><span class="p">});</span>

    <span class="cm">/* accounts for the following cases:</span>
<span class="cm">    YAHOO.util.DataSourceBase.TYPE_UNKNOWN</span>
<span class="cm">    YAHOO.util.DataSourceBase.TYPE_JSARRAY</span>
<span class="cm">    YAHOO.util.DataSourceBase.TYPE_JSON</span>
<span class="cm">    YAHOO.util.DataSourceBase.TYPE_HTMLTABLE</span>
<span class="cm">    YAHOO.util.DataSourceBase.TYPE_XML</span>
<span class="cm">    YAHOO.util.DataSourceBase.TYPE_TEXT</span>
<span class="cm">    */</span>
    <span class="kd">var</span> <span class="nx">oRawResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">liveData</span><span class="p">;</span>
    
    <span class="k">this</span><span class="p">.</span><span class="nx">handleResponse</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oRawResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">,</span> <span class="nx">tId</span><span class="p">);</span>
    <span class="k">return</span> <span class="nx">tId</span><span class="p">;</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Receives raw data response and type converts to XML, JSON, etc as necessary.</span>
<span class="cm"> * Forwards oFullResponse to appropriate parsing function to get turned into</span>
<span class="cm"> * oParsedResponse. Calls doBeforeCallback() and adds oParsedResponse to </span>
<span class="cm"> * the cache when appropriate before calling issueCallback().</span>
<span class="cm"> * </span>
<span class="cm"> * The oParsedResponse object literal has the following properties:</span>
<span class="cm"> * &lt;dl&gt;</span>
<span class="cm"> *     &lt;dd&gt;&lt;dt&gt;tId {Number}&lt;/dt&gt; Unique transaction ID&lt;/dd&gt;</span>
<span class="cm"> *     &lt;dd&gt;&lt;dt&gt;results {Array}&lt;/dt&gt; Array of parsed data results&lt;/dd&gt;</span>
<span class="cm"> *     &lt;dd&gt;&lt;dt&gt;meta {Object}&lt;/dt&gt; Object literal of meta values&lt;/dd&gt; </span>
<span class="cm"> *     &lt;dd&gt;&lt;dt&gt;error {Boolean}&lt;/dt&gt; (optional) True if there was an error&lt;/dd&gt;</span>
<span class="cm"> *     &lt;dd&gt;&lt;dt&gt;cached {Boolean}&lt;/dt&gt; (optional) True if response was cached&lt;/dd&gt;</span>
<span class="cm"> * &lt;/dl&gt;</span>
<span class="cm"> *</span>
<span class="cm"> * @method handleResponse</span>
<span class="cm"> * @param oRequest {Object} Request object</span>
<span class="cm"> * @param oRawResponse {Object} The raw response from the live database.</span>
<span class="cm"> * @param oCallback {Object} Callback object literal.</span>
<span class="cm"> * @param oCaller {Object} (deprecated) Use oCallback.scope.</span>
<span class="cm"> * @param tId {Number} Transaction ID.</span>
<span class="cm"> */</span>
<span class="nx">handleResponse</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oRawResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">,</span> <span class="nx">tId</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;responseEvent&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">tId</span><span class="o">:</span><span class="nx">tId</span><span class="p">,</span> <span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">response</span><span class="o">:</span><span class="nx">oRawResponse</span><span class="p">,</span>
            <span class="nx">callback</span><span class="o">:</span><span class="nx">oCallback</span><span class="p">,</span> <span class="nx">caller</span><span class="o">:</span><span class="nx">oCaller</span><span class="p">});</span>
    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Received live data response for \&quot;&quot;</span> <span class="o">+</span> <span class="nx">oRequest</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="kd">var</span> <span class="nx">xhr</span> <span class="o">=</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">dataType</span> <span class="o">==</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_XHR</span><span class="p">)</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="p">;</span>
    <span class="kd">var</span> <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
    <span class="kd">var</span> <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">oRawResponse</span><span class="p">;</span>
    
    <span class="c1">// Try to sniff data type if it has not been defined</span>
    <span class="k">if</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">===</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_UNKNOWN</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">ctype</span> <span class="o">=</span> <span class="p">(</span><span class="nx">oRawResponse</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">getResponseHeader</span><span class="p">)</span> <span class="o">?</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">getResponseHeader</span><span class="p">[</span><span class="s2">&quot;Content-Type&quot;</span><span class="p">]</span> <span class="o">:</span> <span class="kc">null</span><span class="p">;</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">ctype</span><span class="p">)</span> <span class="p">{</span>
             <span class="c1">// xml</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">ctype</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s2">&quot;text/xml&quot;</span><span class="p">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_XML</span><span class="p">;</span>
            <span class="p">}</span>
            <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">ctype</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s2">&quot;application/json&quot;</span><span class="p">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// json</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSON</span><span class="p">;</span>
            <span class="p">}</span>
            <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">ctype</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s2">&quot;text/plain&quot;</span><span class="p">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// text</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_TEXT</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// array</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSARRAY</span><span class="p">;</span>
            <span class="p">}</span>
             <span class="c1">// xml</span>
            <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">oRawResponse</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeType</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeType</span> <span class="o">===</span> <span class="mi">9</span> <span class="o">||</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeType</span> <span class="o">===</span> <span class="mi">1</span> <span class="o">||</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeType</span> <span class="o">===</span> <span class="mi">11</span><span class="p">))</span> <span class="p">{</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_XML</span><span class="p">;</span>
            <span class="p">}</span>
            <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">oRawResponse</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeName</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeName</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;table&quot;</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// table</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_HTMLTABLE</span><span class="p">;</span>
            <span class="p">}</span>    
            <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// json</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSON</span><span class="p">;</span>
            <span class="p">}</span>
            <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// text</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_TEXT</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">}</span>

    <span class="k">switch</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">responseType</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">case</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSARRAY</span><span class="o">:</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">xhr</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">responseText</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">responseText</span><span class="p">;</span> 
            <span class="p">}</span>
            <span class="k">try</span> <span class="p">{</span>
                <span class="c1">// Convert to JS array if it&#39;s a string</span>
                <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">))</span> <span class="p">{</span>
                    <span class="kd">var</span> <span class="nx">parseArgs</span> <span class="o">=</span> <span class="p">[</span><span class="nx">oFullResponse</span><span class="p">].</span><span class="nx">concat</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">parseJSONArgs</span><span class="p">);</span>
                    <span class="c1">// Check for YUI JSON Util</span>
                    <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">JSON</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">JSON</span><span class="p">,</span><span class="nx">parseArgs</span><span class="p">);</span>
                    <span class="p">}</span>
                    <span class="c1">// Look for JSON parsers using an API similar to json2.js</span>
                    <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">JSON</span> <span class="o">&amp;&amp;</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">JSON</span><span class="p">,</span><span class="nx">parseArgs</span><span class="p">);</span>
                    <span class="p">}</span>
                    <span class="c1">// Look for JSON parsers using an API similar to json.js</span>
                    <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">parseJSON</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">parseJSON</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">,</span><span class="nx">parseArgs</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mi">1</span><span class="p">));</span>
                    <span class="p">}</span>
                    <span class="c1">// No JSON lib found so parse the string</span>
                    <span class="k">else</span> <span class="p">{</span>
                        <span class="c1">// Trim leading spaces</span>
                        <span class="k">while</span> <span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="o">&amp;&amp;</span>
                                <span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">!=</span> <span class="s2">&quot;{&quot;</span><span class="p">)</span> <span class="o">&amp;&amp;</span>
                                <span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">!=</span> <span class="s2">&quot;[&quot;</span><span class="p">))</span> <span class="p">{</span>
                            <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">length</span><span class="p">);</span>
                        <span class="p">}</span>

                        <span class="k">if</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
                            <span class="c1">// Strip extraneous stuff at the end</span>
                            <span class="kd">var</span> <span class="nx">arrayEnd</span> <span class="o">=</span>
<span class="nb">Math</span><span class="p">.</span><span class="nx">max</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s2">&quot;]&quot;</span><span class="p">),</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s2">&quot;}&quot;</span><span class="p">));</span>
                            <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="nx">arrayEnd</span><span class="o">+</span><span class="mi">1</span><span class="p">);</span>

                            <span class="c1">// Turn the string into an object literal...</span>
                            <span class="c1">// ...eval is necessary here</span>
                            <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nb">eval</span><span class="p">(</span><span class="s2">&quot;(&quot;</span> <span class="o">+</span> <span class="nx">oFullResponse</span> <span class="o">+</span> <span class="s2">&quot;)&quot;</span><span class="p">);</span>

                        <span class="p">}</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>
            <span class="k">catch</span><span class="p">(</span><span class="nx">e1</span><span class="p">)</span> <span class="p">{</span>
            <span class="p">}</span>
            <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">doBeforeParseData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">);</span>
            <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">parseArrayData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">);</span>
            <span class="k">break</span><span class="p">;</span>
        <span class="k">case</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSON</span><span class="o">:</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">xhr</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">responseText</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">responseText</span><span class="p">;</span>
            <span class="p">}</span>
            <span class="k">try</span> <span class="p">{</span>
                <span class="c1">// Convert to JSON object if it&#39;s a string</span>
                <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">))</span> <span class="p">{</span>
                    <span class="kd">var</span> <span class="nx">parseArgs</span> <span class="o">=</span> <span class="p">[</span><span class="nx">oFullResponse</span><span class="p">].</span><span class="nx">concat</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">parseJSONArgs</span><span class="p">);</span>
                    <span class="c1">// Check for YUI JSON Util</span>
                    <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">JSON</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">JSON</span><span class="p">,</span><span class="nx">parseArgs</span><span class="p">);</span>
                    <span class="p">}</span>
                    <span class="c1">// Look for JSON parsers using an API similar to json2.js</span>
                    <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">JSON</span> <span class="o">&amp;&amp;</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">JSON</span><span class="p">,</span><span class="nx">parseArgs</span><span class="p">);</span>
                    <span class="p">}</span>
                    <span class="c1">// Look for JSON parsers using an API similar to json.js</span>
                    <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">parseJSON</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">parseJSON</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">,</span><span class="nx">parseArgs</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mi">1</span><span class="p">));</span>
                    <span class="p">}</span>
                    <span class="c1">// No JSON lib found so parse the string</span>
                    <span class="k">else</span> <span class="p">{</span>
                        <span class="c1">// Trim leading spaces</span>
                        <span class="k">while</span> <span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="o">&amp;&amp;</span>
                                <span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">!=</span> <span class="s2">&quot;{&quot;</span><span class="p">)</span> <span class="o">&amp;&amp;</span>
                                <span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">!=</span> <span class="s2">&quot;[&quot;</span><span class="p">))</span> <span class="p">{</span>
                            <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">length</span><span class="p">);</span>
                        <span class="p">}</span>
    
                        <span class="k">if</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
                            <span class="c1">// Strip extraneous stuff at the end</span>
                            <span class="kd">var</span> <span class="nx">objEnd</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">max</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s2">&quot;]&quot;</span><span class="p">),</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s2">&quot;}&quot;</span><span class="p">));</span>
                            <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="nx">objEnd</span><span class="o">+</span><span class="mi">1</span><span class="p">);</span>
    
                            <span class="c1">// Turn the string into an object literal...</span>
                            <span class="c1">// ...eval is necessary here</span>
                            <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nb">eval</span><span class="p">(</span><span class="s2">&quot;(&quot;</span> <span class="o">+</span> <span class="nx">oFullResponse</span> <span class="o">+</span> <span class="s2">&quot;)&quot;</span><span class="p">);</span>
    
                        <span class="p">}</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>
            <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
            <span class="p">}</span>

            <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">doBeforeParseData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">);</span>
            <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">parseJSONData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">);</span>
            <span class="k">break</span><span class="p">;</span>
        <span class="k">case</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_HTMLTABLE</span><span class="o">:</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">xhr</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">responseText</span><span class="p">)</span> <span class="p">{</span>
                <span class="kd">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">&#39;div&#39;</span><span class="p">);</span>
                <span class="nx">el</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">responseText</span><span class="p">;</span>
                <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">el</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">&#39;table&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">];</span>
            <span class="p">}</span>
            <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">doBeforeParseData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">);</span>
            <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">parseHTMLTableData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">);</span>
            <span class="k">break</span><span class="p">;</span>
        <span class="k">case</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_XML</span><span class="o">:</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">xhr</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">responseXML</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">responseXML</span><span class="p">;</span>
            <span class="p">}</span>
            <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">doBeforeParseData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">);</span>
            <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">parseXMLData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">);</span>
            <span class="k">break</span><span class="p">;</span>
        <span class="k">case</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_TEXT</span><span class="o">:</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">xhr</span> <span class="o">&amp;&amp;</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">responseText</span><span class="p">))</span> <span class="p">{</span>
                <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">responseText</span><span class="p">;</span>
            <span class="p">}</span>
            <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">doBeforeParseData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">);</span>
            <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">parseTextData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">);</span>
            <span class="k">break</span><span class="p">;</span>
        <span class="k">default</span><span class="o">:</span>
            <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">doBeforeParseData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">);</span>
            <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">parseData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">);</span>
            <span class="k">break</span><span class="p">;</span>
    <span class="p">}</span>


    <span class="c1">// Clean up for consistent signature</span>
    <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="nx">oParsedResponse</span> <span class="o">||</span> <span class="p">{};</span>
    <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">results</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">results</span> <span class="o">=</span> <span class="p">[];</span>
    <span class="p">}</span>
    <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">meta</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">meta</span> <span class="o">=</span> <span class="p">{};</span>
    <span class="p">}</span>

    <span class="c1">// Success</span>
    <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
        <span class="c1">// Last chance to touch the raw response or the parsed response</span>
        <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">doBeforeCallback</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">,</span> <span class="nx">oParsedResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">);</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;responseParseEvent&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span>
                <span class="nx">response</span><span class="o">:</span><span class="nx">oParsedResponse</span><span class="p">,</span> <span class="nx">callback</span><span class="o">:</span><span class="nx">oCallback</span><span class="p">,</span> <span class="nx">caller</span><span class="o">:</span><span class="nx">oCaller</span><span class="p">});</span>
        <span class="c1">// Cache the response</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">addToCache</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oParsedResponse</span><span class="p">);</span>
    <span class="p">}</span>
    <span class="c1">// Error</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="c1">// Be sure the error flag is on</span>
        <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">error</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;dataErrorEvent&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">response</span><span class="o">:</span> <span class="nx">oRawResponse</span><span class="p">,</span> <span class="nx">callback</span><span class="o">:</span><span class="nx">oCallback</span><span class="p">,</span> 
                <span class="nx">caller</span><span class="o">:</span><span class="nx">oCaller</span><span class="p">,</span> <span class="nx">message</span><span class="o">:</span><span class="nx">DS</span><span class="p">.</span><span class="nx">ERROR_DATANULL</span><span class="p">});</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">DS</span><span class="p">.</span><span class="nx">ERROR_DATANULL</span><span class="p">,</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="p">}</span>

    <span class="c1">// Send the response back to the caller</span>
    <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">tId</span> <span class="o">=</span> <span class="nx">tId</span><span class="p">;</span>
    <span class="nx">DS</span><span class="p">.</span><span class="nx">issueCallback</span><span class="p">(</span><span class="nx">oCallback</span><span class="p">,[</span><span class="nx">oRequest</span><span class="p">,</span><span class="nx">oParsedResponse</span><span class="p">],</span><span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">error</span><span class="p">,</span><span class="nx">oCaller</span><span class="p">);</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Overridable method gives implementers access to the original full response</span>
<span class="cm"> * before the data gets parsed. Implementers should take care not to return an</span>
<span class="cm"> * unparsable or otherwise invalid response.</span>
<span class="cm"> *</span>
<span class="cm"> * @method doBeforeParseData</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oFullResponse {Object} The full response from the live database.</span>
<span class="cm"> * @param oCallback {Object} The callback object.  </span>
<span class="cm"> * @return {Object} Full response for parsing.</span>
<span class="cm">  </span>
<span class="cm"> */</span>
<span class="nx">doBeforeParseData</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">return</span> <span class="nx">oFullResponse</span><span class="p">;</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Overridable method gives implementers access to the original full response and</span>
<span class="cm"> * the parsed response (parsed against the given schema) before the data</span>
<span class="cm"> * is added to the cache (if applicable) and then sent back to callback function.</span>
<span class="cm"> * This is your chance to access the raw response and/or populate the parsed</span>
<span class="cm"> * response with any custom data.</span>
<span class="cm"> *</span>
<span class="cm"> * @method doBeforeCallback</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oFullResponse {Object} The full response from the live database.</span>
<span class="cm"> * @param oParsedResponse {Object} The parsed response to return to calling object.</span>
<span class="cm"> * @param oCallback {Object} The callback object. </span>
<span class="cm"> * @return {Object} Parsed response object.</span>
<span class="cm"> */</span>
<span class="nx">doBeforeCallback</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">,</span> <span class="nx">oParsedResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">return</span> <span class="nx">oParsedResponse</span><span class="p">;</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Overridable method parses data of generic RESPONSE_TYPE into a response object.</span>
<span class="cm"> *</span>
<span class="cm"> * @method parseData</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oFullResponse {Object} The full Array from the live database.</span>
<span class="cm"> * @return {Object} Parsed response object with the following properties:&lt;br&gt;</span>
<span class="cm"> *     - results {Array} Array of parsed data results&lt;br&gt;</span>
<span class="cm"> *     - meta {Object} Object literal of meta values&lt;br&gt;</span>
<span class="cm"> *     - error {Boolean} (optional) True if there was an error&lt;br&gt;</span>
<span class="cm"> */</span>
<span class="nx">parseData</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">))</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="p">{</span><span class="nx">results</span><span class="o">:</span><span class="nx">oFullResponse</span><span class="p">,</span><span class="nx">meta</span><span class="o">:</span><span class="p">{}};</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Parsed generic data is &quot;</span> <span class="o">+</span>
                <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oParsedResponse</span><span class="p">),</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="k">return</span> <span class="nx">oParsedResponse</span><span class="p">;</span>

    <span class="p">}</span>
    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Generic data could not be parsed: &quot;</span> <span class="o">+</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">),</span> 
            <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Overridable method parses Array data into a response object.</span>
<span class="cm"> *</span>
<span class="cm"> * @method parseArrayData</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oFullResponse {Object} The full Array from the live database.</span>
<span class="cm"> * @return {Object} Parsed response object with the following properties:&lt;br&gt;</span>
<span class="cm"> *     - results (Array) Array of parsed data results&lt;br&gt;</span>
<span class="cm"> *     - error (Boolean) True if there was an error</span>
<span class="cm"> */</span>
<span class="nx">parseArrayData</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">))</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">results</span> <span class="o">=</span> <span class="p">[],</span>
            <span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">,</span>
            <span class="nx">rec</span><span class="p">,</span> <span class="nx">field</span><span class="p">,</span> <span class="nx">data</span><span class="p">;</span>
        
        <span class="c1">// Parse for fields</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">.</span><span class="nx">fields</span><span class="p">))</span> <span class="p">{</span>
            <span class="kd">var</span> <span class="nx">fields</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">.</span><span class="nx">fields</span><span class="p">;</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">fields</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">;</span> <span class="o">--</span><span class="nx">i</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">fields</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">!==</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">fields</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> <span class="nx">key</span> <span class="o">:</span> <span class="nx">fields</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="p">};</span>
                <span class="p">}</span>
            <span class="p">}</span>

            <span class="kd">var</span> <span class="nx">parsers</span> <span class="o">=</span> <span class="p">{},</span> <span class="nx">p</span><span class="p">;</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">fields</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">;</span> <span class="o">--</span><span class="nx">i</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">p</span> <span class="o">=</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">fields</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">parser</span> <span class="o">===</span> <span class="s1">&#39;function&#39;</span> <span class="o">?</span>
                          <span class="nx">fields</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">parser</span> <span class="o">:</span>
                          <span class="nx">DS</span><span class="p">.</span><span class="nx">Parser</span><span class="p">[</span><span class="nx">fields</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">parser</span><span class="o">+</span><span class="s1">&#39;&#39;</span><span class="p">])</span> <span class="o">||</span> <span class="nx">fields</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">converter</span><span class="p">;</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">p</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">parsers</span><span class="p">[</span><span class="nx">fields</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">p</span><span class="p">;</span>
                <span class="p">}</span>
            <span class="p">}</span>

            <span class="kd">var</span> <span class="nx">arrType</span> <span class="o">=</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">[</span><span class="mi">0</span><span class="p">]);</span>
            <span class="k">for</span><span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span><span class="o">&gt;-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
                <span class="kd">var</span> <span class="nx">oResult</span> <span class="o">=</span> <span class="p">{};</span>
                <span class="nx">rec</span> <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
                <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">rec</span> <span class="o">===</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span>
                    <span class="k">for</span><span class="p">(</span><span class="nx">j</span><span class="o">=</span><span class="nx">fields</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">j</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">field</span> <span class="o">=</span> <span class="nx">fields</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span>
                        <span class="nx">data</span> <span class="o">=</span> <span class="nx">arrType</span> <span class="o">?</span> <span class="nx">rec</span><span class="p">[</span><span class="nx">j</span><span class="p">]</span> <span class="o">:</span> <span class="nx">rec</span><span class="p">[</span><span class="nx">field</span><span class="p">.</span><span class="nx">key</span><span class="p">];</span>

                        <span class="k">if</span> <span class="p">(</span><span class="nx">parsers</span><span class="p">[</span><span class="nx">field</span><span class="p">.</span><span class="nx">key</span><span class="p">])</span> <span class="p">{</span>
                            <span class="nx">data</span> <span class="o">=</span> <span class="nx">parsers</span><span class="p">[</span><span class="nx">field</span><span class="p">.</span><span class="nx">key</span><span class="p">].</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span><span class="nx">data</span><span class="p">);</span>
                        <span class="p">}</span>

                        <span class="c1">// Safety measure</span>
                        <span class="k">if</span><span class="p">(</span><span class="nx">data</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
                            <span class="nx">data</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
                        <span class="p">}</span>

                        <span class="nx">oResult</span><span class="p">[</span><span class="nx">field</span><span class="p">.</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">data</span><span class="p">;</span>
                    <span class="p">}</span>
                <span class="p">}</span>
                <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">rec</span><span class="p">))</span> <span class="p">{</span>
                    <span class="k">for</span><span class="p">(</span><span class="nx">j</span><span class="o">=</span><span class="nx">fields</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">j</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">field</span> <span class="o">=</span> <span class="nx">fields</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span>
                        <span class="nx">data</span> <span class="o">=</span> <span class="nx">rec</span><span class="p">;</span>

                        <span class="k">if</span> <span class="p">(</span><span class="nx">parsers</span><span class="p">[</span><span class="nx">field</span><span class="p">.</span><span class="nx">key</span><span class="p">])</span> <span class="p">{</span>
                            <span class="nx">data</span> <span class="o">=</span> <span class="nx">parsers</span><span class="p">[</span><span class="nx">field</span><span class="p">.</span><span class="nx">key</span><span class="p">].</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span><span class="nx">data</span><span class="p">);</span>
                        <span class="p">}</span>

                        <span class="c1">// Safety measure</span>
                        <span class="k">if</span><span class="p">(</span><span class="nx">data</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
                            <span class="nx">data</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
                        <span class="p">}</span>

                        <span class="nx">oResult</span><span class="p">[</span><span class="nx">field</span><span class="p">.</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">data</span><span class="p">;</span>
                    <span class="p">}</span>                
                <span class="p">}</span>
                <span class="nx">results</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">oResult</span><span class="p">;</span>
            <span class="p">}</span>    
        <span class="p">}</span>
        <span class="c1">// Return entire data set</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="nx">results</span> <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="kd">var</span> <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="p">{</span><span class="nx">results</span><span class="o">:</span><span class="nx">results</span><span class="p">};</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Parsed array data is &quot;</span> <span class="o">+</span>
                <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oParsedResponse</span><span class="p">),</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="k">return</span> <span class="nx">oParsedResponse</span><span class="p">;</span>

    <span class="p">}</span>
    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Array data could not be parsed: &quot;</span> <span class="o">+</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">),</span> 
            <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Overridable method parses plain text data into a response object.</span>
<span class="cm"> *</span>
<span class="cm"> * @method parseTextData</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oFullResponse {Object} The full text response from the live database.</span>
<span class="cm"> * @return {Object} Parsed response object with the following properties:&lt;br&gt;</span>
<span class="cm"> *     - results (Array) Array of parsed data results&lt;br&gt;</span>
<span class="cm"> *     - error (Boolean) True if there was an error</span>
<span class="cm"> */</span>
<span class="nx">parseTextData</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">.</span><span class="nx">recordDelim</span><span class="p">)</span> <span class="o">&amp;&amp;</span>
                <span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">.</span><span class="nx">fieldDelim</span><span class="p">))</span> <span class="p">{</span>
            <span class="kd">var</span> <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="p">{</span><span class="nx">results</span><span class="o">:</span><span class="p">[]};</span>
            <span class="kd">var</span> <span class="nx">recDelim</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">.</span><span class="nx">recordDelim</span><span class="p">;</span>
            <span class="kd">var</span> <span class="nx">fieldDelim</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">.</span><span class="nx">fieldDelim</span><span class="p">;</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
                <span class="c1">// Delete the last line delimiter at the end of the data if it exists</span>
                <span class="kd">var</span> <span class="nx">newLength</span> <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="nx">recDelim</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>
                <span class="k">if</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="nx">newLength</span><span class="p">)</span> <span class="o">==</span> <span class="nx">recDelim</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">oFullResponse</span> <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nx">newLength</span><span class="p">);</span>
                <span class="p">}</span>
                <span class="k">if</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
                    <span class="c1">// Split along record delimiter to get an array of strings</span>
                    <span class="kd">var</span> <span class="nx">recordsarray</span> <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="nx">recDelim</span><span class="p">);</span>
                    <span class="c1">// Cycle through each record</span>
                    <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">len</span> <span class="o">=</span> <span class="nx">recordsarray</span><span class="p">.</span><span class="nx">length</span><span class="p">,</span> <span class="nx">recIdx</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">len</span><span class="p">;</span> <span class="o">++</span><span class="nx">i</span><span class="p">)</span> <span class="p">{</span>
                        <span class="kd">var</span> <span class="nx">bError</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span>
                            <span class="nx">sRecord</span> <span class="o">=</span> <span class="nx">recordsarray</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
                        <span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">sRecord</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">sRecord</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">))</span> <span class="p">{</span>
                            <span class="c1">// Split each record along field delimiter to get data</span>
                            <span class="kd">var</span> <span class="nx">fielddataarray</span> <span class="o">=</span> <span class="nx">recordsarray</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">split</span><span class="p">(</span><span class="nx">fieldDelim</span><span class="p">);</span>
                            <span class="kd">var</span> <span class="nx">oResult</span> <span class="o">=</span> <span class="p">{};</span>
                            
                            <span class="c1">// Filter for fields data</span>
                            <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">.</span><span class="nx">fields</span><span class="p">))</span> <span class="p">{</span>
                                <span class="kd">var</span> <span class="nx">fields</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">.</span><span class="nx">fields</span><span class="p">;</span>
                                <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">j</span><span class="o">=</span><span class="nx">fields</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">j</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
                                    <span class="k">try</span> <span class="p">{</span>
                                        <span class="c1">// Remove quotation marks from edges, if applicable</span>
                                        <span class="kd">var</span> <span class="nx">data</span> <span class="o">=</span> <span class="nx">fielddataarray</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span>
                                        <span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">data</span><span class="p">))</span> <span class="p">{</span>
                                            <span class="k">if</span><span class="p">(</span><span class="nx">data</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;\&quot;&quot;</span><span class="p">)</span> <span class="p">{</span>
                                                <span class="nx">data</span> <span class="o">=</span> <span class="nx">data</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
                                            <span class="p">}</span>
                                            <span class="k">if</span><span class="p">(</span><span class="nx">data</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="nx">data</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;\&quot;&quot;</span><span class="p">)</span> <span class="p">{</span>
                                                <span class="nx">data</span> <span class="o">=</span> <span class="nx">data</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="nx">data</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">);</span>
                                            <span class="p">}</span>
                                            <span class="kd">var</span> <span class="nx">field</span> <span class="o">=</span> <span class="nx">fields</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span>
                                            <span class="kd">var</span> <span class="nx">key</span> <span class="o">=</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">field</span><span class="p">.</span><span class="nx">key</span><span class="p">))</span> <span class="o">?</span> <span class="nx">field</span><span class="p">.</span><span class="nx">key</span> <span class="o">:</span> <span class="nx">field</span><span class="p">;</span>
                                            <span class="c1">// Backward compatibility</span>
                                            <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">&amp;&amp;</span> <span class="nx">field</span><span class="p">.</span><span class="nx">converter</span><span class="p">)</span> <span class="p">{</span>
                                                <span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">=</span> <span class="nx">field</span><span class="p">.</span><span class="nx">converter</span><span class="p">;</span>
                                                <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;The field property converter has been deprecated&quot;</span> <span class="o">+</span>
                                                        <span class="s2">&quot; in favor of parser&quot;</span><span class="p">,</span> <span class="s2">&quot;warn&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
                                            <span class="p">}</span>
                                            <span class="kd">var</span> <span class="nx">parser</span> <span class="o">=</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">===</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="o">?</span>
                                                <span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">:</span>
                                                <span class="nx">DS</span><span class="p">.</span><span class="nx">Parser</span><span class="p">[</span><span class="nx">field</span><span class="p">.</span><span class="nx">parser</span><span class="o">+</span><span class="s1">&#39;&#39;</span><span class="p">];</span>
                                            <span class="k">if</span><span class="p">(</span><span class="nx">parser</span><span class="p">)</span> <span class="p">{</span>
                                                <span class="nx">data</span> <span class="o">=</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">data</span><span class="p">);</span>
                                            <span class="p">}</span>
                                            <span class="c1">// Safety measure</span>
                                            <span class="k">if</span><span class="p">(</span><span class="nx">data</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
                                                <span class="nx">data</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
                                            <span class="p">}</span>
                                            <span class="nx">oResult</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">data</span><span class="p">;</span>
                                        <span class="p">}</span>
                                        <span class="k">else</span> <span class="p">{</span>
                                            <span class="nx">bError</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                                        <span class="p">}</span>
                                    <span class="p">}</span>
                                    <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
                                        <span class="nx">bError</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                                    <span class="p">}</span>
                                <span class="p">}</span>
                            <span class="p">}</span>            
                            <span class="c1">// No fields defined so pass along all data as an array</span>
                            <span class="k">else</span> <span class="p">{</span>
                                <span class="nx">oResult</span> <span class="o">=</span> <span class="nx">fielddataarray</span><span class="p">;</span>
                            <span class="p">}</span>
                            <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">bError</span><span class="p">)</span> <span class="p">{</span>
                                <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">results</span><span class="p">[</span><span class="nx">recIdx</span><span class="o">++</span><span class="p">]</span> <span class="o">=</span> <span class="nx">oResult</span><span class="p">;</span>
                            <span class="p">}</span>
                        <span class="p">}</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>
            <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Parsed text data is &quot;</span> <span class="o">+</span>
                    <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oParsedResponse</span><span class="p">),</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
            <span class="k">return</span> <span class="nx">oParsedResponse</span><span class="p">;</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Text data could not be parsed: &quot;</span> <span class="o">+</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">),</span> 
            <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
            
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Overridable method parses XML data for one result into an object literal.</span>
<span class="cm"> *</span>
<span class="cm"> * @method parseXMLResult</span>
<span class="cm"> * @param result {XML} XML for one result.</span>
<span class="cm"> * @return {Object} Object literal of data for one result.</span>
<span class="cm"> */</span>
<span class="nx">parseXMLResult</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">result</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">oResult</span> <span class="o">=</span> <span class="p">{},</span>
        <span class="nx">schema</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">;</span>
        
    <span class="k">try</span> <span class="p">{</span>
        <span class="c1">// Loop through each data field in each result using the schema</span>
        <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">m</span> <span class="o">=</span> <span class="nx">schema</span><span class="p">.</span><span class="nx">fields</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">m</span> <span class="o">&gt;=</span> <span class="mi">0</span> <span class="p">;</span> <span class="nx">m</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
            <span class="kd">var</span> <span class="nx">field</span> <span class="o">=</span> <span class="nx">schema</span><span class="p">.</span><span class="nx">fields</span><span class="p">[</span><span class="nx">m</span><span class="p">];</span>
            <span class="kd">var</span> <span class="nx">key</span> <span class="o">=</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">field</span><span class="p">.</span><span class="nx">key</span><span class="p">))</span> <span class="o">?</span> <span class="nx">field</span><span class="p">.</span><span class="nx">key</span> <span class="o">:</span> <span class="nx">field</span><span class="p">;</span>
            <span class="kd">var</span> <span class="nx">data</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>

            <span class="k">if</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">useXPath</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">data</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">util</span><span class="p">.</span><span class="nx">DataSource</span><span class="p">.</span><span class="nx">_getLocationValue</span><span class="p">(</span><span class="nx">field</span><span class="p">,</span> <span class="nx">result</span><span class="p">);</span>
            <span class="p">}</span>
            <span class="k">else</span> <span class="p">{</span>
                <span class="c1">// Values may be held in an attribute...</span>
                <span class="kd">var</span> <span class="nx">xmlAttr</span> <span class="o">=</span> <span class="nx">result</span><span class="p">.</span><span class="nx">attributes</span><span class="p">.</span><span class="nx">getNamedItem</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span>
                <span class="k">if</span><span class="p">(</span><span class="nx">xmlAttr</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">data</span> <span class="o">=</span> <span class="nx">xmlAttr</span><span class="p">.</span><span class="nx">value</span><span class="p">;</span>
                <span class="p">}</span>
                <span class="c1">// ...or in a node</span>
                <span class="k">else</span> <span class="p">{</span>
                    <span class="kd">var</span> <span class="nx">xmlNode</span> <span class="o">=</span> <span class="nx">result</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span>
                    <span class="k">if</span><span class="p">(</span><span class="nx">xmlNode</span> <span class="o">&amp;&amp;</span> <span class="nx">xmlNode</span><span class="p">.</span><span class="nx">item</span><span class="p">(</span><span class="mi">0</span><span class="p">))</span> <span class="p">{</span>
                        <span class="kd">var</span> <span class="nx">item</span> <span class="o">=</span> <span class="nx">xmlNode</span><span class="p">.</span><span class="nx">item</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
                        <span class="c1">// For IE, then DOM...</span>
                        <span class="nx">data</span> <span class="o">=</span> <span class="p">(</span><span class="nx">item</span><span class="p">)</span> <span class="o">?</span> <span class="p">((</span><span class="nx">item</span><span class="p">.</span><span class="nx">text</span><span class="p">)</span> <span class="o">?</span> <span class="nx">item</span><span class="p">.</span><span class="nx">text</span> <span class="o">:</span> <span class="p">(</span><span class="nx">item</span><span class="p">.</span><span class="nx">textContent</span><span class="p">)</span> <span class="o">?</span> <span class="nx">item</span><span class="p">.</span><span class="nx">textContent</span> <span class="o">:</span> <span class="kc">null</span><span class="p">)</span> <span class="o">:</span> <span class="kc">null</span><span class="p">;</span>
                        <span class="c1">// ...then fallback, but check for multiple child nodes</span>
                        <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
                            <span class="kd">var</span> <span class="nx">datapieces</span> <span class="o">=</span> <span class="p">[];</span>
                            <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">j</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="nx">len</span><span class="o">=</span><span class="nx">item</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">len</span><span class="p">;</span> <span class="nx">j</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                                <span class="k">if</span><span class="p">(</span><span class="nx">item</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">[</span><span class="nx">j</span><span class="p">].</span><span class="nx">nodeValue</span><span class="p">)</span> <span class="p">{</span>
                                    <span class="nx">datapieces</span><span class="p">[</span><span class="nx">datapieces</span><span class="p">.</span><span class="nx">length</span><span class="p">]</span> <span class="o">=</span> <span class="nx">item</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">[</span><span class="nx">j</span><span class="p">].</span><span class="nx">nodeValue</span><span class="p">;</span>
                                <span class="p">}</span>
                            <span class="p">}</span>
                            <span class="k">if</span><span class="p">(</span><span class="nx">datapieces</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
                                <span class="nx">data</span> <span class="o">=</span> <span class="nx">datapieces</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">);</span>
                            <span class="p">}</span>
                        <span class="p">}</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>
            
            
            <span class="c1">// Safety net</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">data</span> <span class="o">===</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span>
                   <span class="nx">data</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">;</span>
            <span class="p">}</span>
            <span class="c1">// Backward compatibility</span>
            <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">&amp;&amp;</span> <span class="nx">field</span><span class="p">.</span><span class="nx">converter</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">=</span> <span class="nx">field</span><span class="p">.</span><span class="nx">converter</span><span class="p">;</span>
                <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;The field property converter has been deprecated&quot;</span> <span class="o">+</span>
                        <span class="s2">&quot; in favor of parser&quot;</span><span class="p">,</span> <span class="s2">&quot;warn&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
            <span class="p">}</span>
            <span class="kd">var</span> <span class="nx">parser</span> <span class="o">=</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">===</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="o">?</span>
                <span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">:</span>
                <span class="nx">DS</span><span class="p">.</span><span class="nx">Parser</span><span class="p">[</span><span class="nx">field</span><span class="p">.</span><span class="nx">parser</span><span class="o">+</span><span class="s1">&#39;&#39;</span><span class="p">];</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">parser</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">data</span> <span class="o">=</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">data</span><span class="p">);</span>
            <span class="p">}</span>
            <span class="c1">// Safety measure</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">data</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">data</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
            <span class="p">}</span>
            <span class="nx">oResult</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">data</span><span class="p">;</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Error while parsing XML result: &quot;</span> <span class="o">+</span> <span class="nx">e</span><span class="p">.</span><span class="nx">message</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="k">return</span> <span class="nx">oResult</span><span class="p">;</span>
<span class="p">},</span>



<span class="cm">/**</span>
<span class="cm"> * Overridable method parses XML data into a response object.</span>
<span class="cm"> *</span>
<span class="cm"> * @method parseXMLData</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oFullResponse {Object} The full XML response from the live database.</span>
<span class="cm"> * @return {Object} Parsed response object with the following properties&lt;br&gt;</span>
<span class="cm"> *     - results (Array) Array of parsed data results&lt;br&gt;</span>
<span class="cm"> *     - error (Boolean) True if there was an error</span>
<span class="cm"> */</span>
<span class="nx">parseXMLData</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">bError</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span>
        <span class="nx">schema</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">,</span>
        <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="p">{</span><span class="nx">meta</span><span class="o">:</span><span class="p">{}},</span>
        <span class="nx">xmlList</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span>
        <span class="nx">metaNode</span>      <span class="o">=</span> <span class="nx">schema</span><span class="p">.</span><span class="nx">metaNode</span><span class="p">,</span>
        <span class="nx">metaLocators</span>  <span class="o">=</span> <span class="nx">schema</span><span class="p">.</span><span class="nx">metaFields</span> <span class="o">||</span> <span class="p">{},</span>
        <span class="nx">i</span><span class="p">,</span><span class="nx">k</span><span class="p">,</span><span class="nx">loc</span><span class="p">,</span><span class="nx">v</span><span class="p">;</span>

    <span class="c1">// In case oFullResponse is something funky</span>
    <span class="k">try</span> <span class="p">{</span>
        <span class="c1">// Pull any meta identified</span>
        <span class="k">if</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">useXPath</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">k</span> <span class="k">in</span> <span class="nx">metaLocators</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">meta</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">util</span><span class="p">.</span><span class="nx">DataSource</span><span class="p">.</span><span class="nx">_getLocationValue</span><span class="p">(</span><span class="nx">metaLocators</span><span class="p">[</span><span class="nx">k</span><span class="p">],</span> <span class="nx">oFullResponse</span><span class="p">);</span>
            <span class="p">}</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="nx">metaNode</span> <span class="o">=</span> <span class="nx">metaNode</span> <span class="o">?</span> <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="nx">metaNode</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> <span class="o">:</span>
                       <span class="nx">oFullResponse</span><span class="p">;</span>

            <span class="k">if</span> <span class="p">(</span><span class="nx">metaNode</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">for</span> <span class="p">(</span><span class="nx">k</span> <span class="k">in</span> <span class="nx">metaLocators</span><span class="p">)</span> <span class="p">{</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">metaLocators</span><span class="p">,</span> <span class="nx">k</span><span class="p">))</span> <span class="p">{</span>
                        <span class="nx">loc</span> <span class="o">=</span> <span class="nx">metaLocators</span><span class="p">[</span><span class="nx">k</span><span class="p">];</span>
                        <span class="c1">// Look for a node</span>
                        <span class="nx">v</span> <span class="o">=</span> <span class="nx">metaNode</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="nx">loc</span><span class="p">)[</span><span class="mi">0</span><span class="p">];</span>

                        <span class="k">if</span> <span class="p">(</span><span class="nx">v</span><span class="p">)</span> <span class="p">{</span>
                            <span class="nx">v</span> <span class="o">=</span> <span class="nx">v</span><span class="p">.</span><span class="nx">firstChild</span><span class="p">.</span><span class="nx">nodeValue</span><span class="p">;</span>
                        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                            <span class="c1">// Look for an attribute</span>
                            <span class="nx">v</span> <span class="o">=</span> <span class="nx">metaNode</span><span class="p">.</span><span class="nx">attributes</span><span class="p">.</span><span class="nx">getNamedItem</span><span class="p">(</span><span class="nx">loc</span><span class="p">);</span>
                            <span class="k">if</span> <span class="p">(</span><span class="nx">v</span><span class="p">)</span> <span class="p">{</span>
                                <span class="nx">v</span> <span class="o">=</span> <span class="nx">v</span><span class="p">.</span><span class="nx">value</span><span class="p">;</span>
                            <span class="p">}</span>
                        <span class="p">}</span>

                        <span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">v</span><span class="p">))</span> <span class="p">{</span>
                            <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">meta</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">=</span> <span class="nx">v</span><span class="p">;</span>
                        <span class="p">}</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>
        
        <span class="c1">// For result data</span>
        <span class="nx">xmlList</span> <span class="o">=</span> <span class="p">(</span><span class="nx">schema</span><span class="p">.</span><span class="nx">resultNode</span><span class="p">)</span> <span class="o">?</span>
            <span class="nx">oFullResponse</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="nx">schema</span><span class="p">.</span><span class="nx">resultNode</span><span class="p">)</span> <span class="o">:</span>
            <span class="kc">null</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">catch</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Error while parsing XML data: &quot;</span> <span class="o">+</span> <span class="nx">e</span><span class="p">.</span><span class="nx">message</span><span class="p">);</span>
    <span class="p">}</span>
    <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">xmlList</span> <span class="o">||</span> <span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">schema</span><span class="p">.</span><span class="nx">fields</span><span class="p">))</span> <span class="p">{</span>
        <span class="nx">bError</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="c1">// Loop through each result</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">results</span> <span class="o">=</span> <span class="p">[];</span>
        <span class="k">for</span><span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">xmlList</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&gt;=</span> <span class="mi">0</span> <span class="p">;</span> <span class="o">--</span><span class="nx">i</span><span class="p">)</span> <span class="p">{</span>
            <span class="kd">var</span> <span class="nx">oResult</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">parseXMLResult</span><span class="p">(</span><span class="nx">xmlList</span><span class="p">.</span><span class="nx">item</span><span class="p">(</span><span class="nx">i</span><span class="p">));</span>
            <span class="c1">// Capture each array of values into an array of results</span>
            <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">results</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">oResult</span><span class="p">;</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">bError</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;XML data could not be parsed: &quot;</span> <span class="o">+</span>
                <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">),</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">error</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Parsed XML data is &quot;</span> <span class="o">+</span>
                <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oParsedResponse</span><span class="p">),</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="p">}</span>
    <span class="k">return</span> <span class="nx">oParsedResponse</span><span class="p">;</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Overridable method parses JSON data into a response object.</span>
<span class="cm"> *</span>
<span class="cm"> * @method parseJSONData</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oFullResponse {Object} The full JSON from the live database.</span>
<span class="cm"> * @return {Object} Parsed response object with the following properties&lt;br&gt;</span>
<span class="cm"> *     - results (Array) Array of parsed data results&lt;br&gt;</span>
<span class="cm"> *     - error (Boolean) True if there was an error</span>
<span class="cm"> */</span>
<span class="nx">parseJSONData</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="p">{</span><span class="nx">results</span><span class="o">:</span><span class="p">[],</span><span class="nx">meta</span><span class="o">:</span><span class="p">{}};</span>
    
    <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">.</span><span class="nx">resultsList</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">schema</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">,</span>
            <span class="nx">fields</span>          <span class="o">=</span> <span class="nx">schema</span><span class="p">.</span><span class="nx">fields</span><span class="p">,</span>
            <span class="nx">resultsList</span>     <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">,</span>
            <span class="nx">results</span>         <span class="o">=</span> <span class="p">[],</span>
            <span class="nx">metaFields</span>      <span class="o">=</span> <span class="nx">schema</span><span class="p">.</span><span class="nx">metaFields</span> <span class="o">||</span> <span class="p">{},</span>
            <span class="nx">fieldParsers</span>    <span class="o">=</span> <span class="p">[],</span>
            <span class="nx">fieldPaths</span>      <span class="o">=</span> <span class="p">[],</span>
            <span class="nx">simpleFields</span>    <span class="o">=</span> <span class="p">[],</span>
            <span class="nx">bError</span>          <span class="o">=</span> <span class="kc">false</span><span class="p">,</span>
            <span class="nx">i</span><span class="p">,</span><span class="nx">len</span><span class="p">,</span><span class="nx">j</span><span class="p">,</span><span class="nx">v</span><span class="p">,</span><span class="nx">key</span><span class="p">,</span><span class="nx">parser</span><span class="p">,</span><span class="nx">path</span><span class="p">;</span>

        <span class="c1">// Function to convert the schema&#39;s fields into walk paths</span>
        <span class="kd">var</span> <span class="nx">buildPath</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">needle</span><span class="p">)</span> <span class="p">{</span>
            <span class="kd">var</span> <span class="nx">path</span> <span class="o">=</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">keys</span> <span class="o">=</span> <span class="p">[],</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">needle</span><span class="p">)</span> <span class="p">{</span>
                <span class="c1">// Strip the [&quot;string keys&quot;] and [1] array indexes</span>
                <span class="nx">needle</span> <span class="o">=</span> <span class="nx">needle</span><span class="p">.</span>
                    <span class="nx">replace</span><span class="p">(</span><span class="sr">/\[([&#39;&quot;])(.*?)\1\]/g</span><span class="p">,</span>
                    <span class="kd">function</span> <span class="p">(</span><span class="nx">x</span><span class="p">,</span><span class="nx">$1</span><span class="p">,</span><span class="nx">$2</span><span class="p">)</span> <span class="p">{</span><span class="nx">keys</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="o">=</span><span class="nx">$2</span><span class="p">;</span><span class="k">return</span> <span class="s1">&#39;.@&#39;</span><span class="o">+</span><span class="p">(</span><span class="nx">i</span><span class="o">++</span><span class="p">);}).</span>
                    <span class="nx">replace</span><span class="p">(</span><span class="sr">/\[(\d+)\]/g</span><span class="p">,</span>
                    <span class="kd">function</span> <span class="p">(</span><span class="nx">x</span><span class="p">,</span><span class="nx">$1</span><span class="p">)</span> <span class="p">{</span><span class="nx">keys</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="o">=</span><span class="nb">parseInt</span><span class="p">(</span><span class="nx">$1</span><span class="p">,</span><span class="mi">10</span><span class="p">)</span><span class="o">|</span><span class="mi">0</span><span class="p">;</span><span class="k">return</span> <span class="s1">&#39;.@&#39;</span><span class="o">+</span><span class="p">(</span><span class="nx">i</span><span class="o">++</span><span class="p">);}).</span>
                    <span class="nx">replace</span><span class="p">(</span><span class="sr">/^\./</span><span class="p">,</span><span class="s1">&#39;&#39;</span><span class="p">);</span> <span class="c1">// remove leading dot</span>

                <span class="c1">// If the cleaned needle contains invalid characters, the</span>
                <span class="c1">// path is invalid</span>
                <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="sr">/[^\w\.\$@]/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">needle</span><span class="p">))</span> <span class="p">{</span>
                    <span class="nx">path</span> <span class="o">=</span> <span class="nx">needle</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;.&#39;</span><span class="p">);</span>
                    <span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">path</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">;</span> <span class="o">--</span><span class="nx">i</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">if</span> <span class="p">(</span><span class="nx">path</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">charAt</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">===</span> <span class="s1">&#39;@&#39;</span><span class="p">)</span> <span class="p">{</span>
                            <span class="nx">path</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">keys</span><span class="p">[</span><span class="nb">parseInt</span><span class="p">(</span><span class="nx">path</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">substr</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span><span class="mi">10</span><span class="p">)];</span>
                        <span class="p">}</span>
                    <span class="p">}</span>
                <span class="p">}</span>
                <span class="k">else</span> <span class="p">{</span>
                    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Invalid locator: &quot;</span> <span class="o">+</span> <span class="nx">needle</span><span class="p">,</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
                <span class="p">}</span>
            <span class="p">}</span>
            <span class="k">return</span> <span class="nx">path</span><span class="p">;</span>
        <span class="p">};</span>


        <span class="c1">// Function to walk a path and return the pot of gold</span>
        <span class="kd">var</span> <span class="nx">walkPath</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">path</span><span class="p">,</span> <span class="nx">origin</span><span class="p">)</span> <span class="p">{</span>
            <span class="kd">var</span> <span class="nx">v</span><span class="o">=</span><span class="nx">origin</span><span class="p">,</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span><span class="nx">len</span><span class="o">=</span><span class="nx">path</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>
            <span class="k">for</span> <span class="p">(;</span><span class="nx">i</span><span class="o">&lt;</span><span class="nx">len</span> <span class="o">&amp;&amp;</span> <span class="nx">v</span><span class="p">;</span><span class="o">++</span><span class="nx">i</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">v</span> <span class="o">=</span> <span class="nx">v</span><span class="p">[</span><span class="nx">path</span><span class="p">[</span><span class="nx">i</span><span class="p">]];</span>
            <span class="p">}</span>
            <span class="k">return</span> <span class="nx">v</span><span class="p">;</span>
        <span class="p">};</span>

        <span class="c1">// Parse the response</span>
        <span class="c1">// Step 1. Pull the resultsList from oFullResponse (default assumes</span>
        <span class="c1">// oFullResponse IS the resultsList)</span>
        <span class="nx">path</span> <span class="o">=</span> <span class="nx">buildPath</span><span class="p">(</span><span class="nx">schema</span><span class="p">.</span><span class="nx">resultsList</span><span class="p">);</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">path</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">resultsList</span> <span class="o">=</span> <span class="nx">walkPath</span><span class="p">(</span><span class="nx">path</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">);</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">resultsList</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">bError</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
            <span class="nx">bError</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
        <span class="p">}</span>
        
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">resultsList</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">resultsList</span> <span class="o">=</span> <span class="p">[];</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">resultsList</span><span class="p">))</span> <span class="p">{</span>
            <span class="nx">resultsList</span> <span class="o">=</span> <span class="p">[</span><span class="nx">resultsList</span><span class="p">];</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">bError</span><span class="p">)</span> <span class="p">{</span>
            <span class="c1">// Step 2. Parse out field data if identified</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">schema</span><span class="p">.</span><span class="nx">fields</span><span class="p">)</span> <span class="p">{</span>
                <span class="kd">var</span> <span class="nx">field</span><span class="p">;</span>
                <span class="c1">// Build the field parser map and location paths</span>
                <span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="nx">len</span><span class="o">=</span><span class="nx">fields</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">len</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">field</span> <span class="o">=</span> <span class="nx">fields</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
                    <span class="nx">key</span>    <span class="o">=</span> <span class="nx">field</span><span class="p">.</span><span class="nx">key</span> <span class="o">||</span> <span class="nx">field</span><span class="p">;</span>
                    <span class="nx">parser</span> <span class="o">=</span> <span class="p">((</span><span class="k">typeof</span> <span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">===</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="o">?</span>
                        <span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">:</span>
                        <span class="nx">DS</span><span class="p">.</span><span class="nx">Parser</span><span class="p">[</span><span class="nx">field</span><span class="p">.</span><span class="nx">parser</span><span class="o">+</span><span class="s1">&#39;&#39;</span><span class="p">])</span> <span class="o">||</span> <span class="nx">field</span><span class="p">.</span><span class="nx">converter</span><span class="p">;</span>
                    <span class="nx">path</span>   <span class="o">=</span> <span class="nx">buildPath</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span>
    
                    <span class="k">if</span> <span class="p">(</span><span class="nx">parser</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">fieldParsers</span><span class="p">[</span><span class="nx">fieldParsers</span><span class="p">.</span><span class="nx">length</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="nx">key</span><span class="o">:</span><span class="nx">key</span><span class="p">,</span><span class="nx">parser</span><span class="o">:</span><span class="nx">parser</span><span class="p">};</span>
                    <span class="p">}</span>
    
                    <span class="k">if</span> <span class="p">(</span><span class="nx">path</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">if</span> <span class="p">(</span><span class="nx">path</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
                            <span class="nx">fieldPaths</span><span class="p">[</span><span class="nx">fieldPaths</span><span class="p">.</span><span class="nx">length</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="nx">key</span><span class="o">:</span><span class="nx">key</span><span class="p">,</span><span class="nx">path</span><span class="o">:</span><span class="nx">path</span><span class="p">};</span>
                        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                            <span class="nx">simpleFields</span><span class="p">[</span><span class="nx">simpleFields</span><span class="p">.</span><span class="nx">length</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="nx">key</span><span class="o">:</span><span class="nx">key</span><span class="p">,</span><span class="nx">path</span><span class="o">:</span><span class="nx">path</span><span class="p">[</span><span class="mi">0</span><span class="p">]};</span>
                        <span class="p">}</span>
                    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Invalid key syntax: &quot;</span> <span class="o">+</span> <span class="nx">key</span><span class="p">,</span><span class="s2">&quot;warn&quot;</span><span class="p">,</span><span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
                    <span class="p">}</span>
                <span class="p">}</span>

                <span class="c1">// Process the results, flattening the records and/or applying parsers if needed</span>
                <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="nx">resultsList</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">;</span> <span class="o">--</span><span class="nx">i</span><span class="p">)</span> <span class="p">{</span>
                    <span class="kd">var</span> <span class="nx">r</span> <span class="o">=</span> <span class="nx">resultsList</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span> <span class="nx">rec</span> <span class="o">=</span> <span class="p">{};</span>
                    <span class="k">if</span><span class="p">(</span><span class="nx">r</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="nx">simpleFields</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">;</span> <span class="o">--</span><span class="nx">j</span><span class="p">)</span> <span class="p">{</span>
                            <span class="c1">// Bug 1777850: data might be held in an array</span>
                            <span class="nx">rec</span><span class="p">[</span><span class="nx">simpleFields</span><span class="p">[</span><span class="nx">j</span><span class="p">].</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span>
                                    <span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="nx">simpleFields</span><span class="p">[</span><span class="nx">j</span><span class="p">].</span><span class="nx">path</span><span class="p">]</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="p">)</span> <span class="o">?</span>
                                    <span class="nx">r</span><span class="p">[</span><span class="nx">simpleFields</span><span class="p">[</span><span class="nx">j</span><span class="p">].</span><span class="nx">path</span><span class="p">]</span> <span class="o">:</span> <span class="nx">r</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span>
                        <span class="p">}</span>

                        <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="nx">fieldPaths</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">;</span> <span class="o">--</span><span class="nx">j</span><span class="p">)</span> <span class="p">{</span>
                            <span class="nx">rec</span><span class="p">[</span><span class="nx">fieldPaths</span><span class="p">[</span><span class="nx">j</span><span class="p">].</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">walkPath</span><span class="p">(</span><span class="nx">fieldPaths</span><span class="p">[</span><span class="nx">j</span><span class="p">].</span><span class="nx">path</span><span class="p">,</span><span class="nx">r</span><span class="p">);</span>
                        <span class="p">}</span>

                        <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="nx">fieldParsers</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">;</span> <span class="o">--</span><span class="nx">j</span><span class="p">)</span> <span class="p">{</span>
                            <span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="nx">fieldParsers</span><span class="p">[</span><span class="nx">j</span><span class="p">].</span><span class="nx">key</span><span class="p">;</span>
                            <span class="nx">rec</span><span class="p">[</span><span class="nx">p</span><span class="p">]</span> <span class="o">=</span> <span class="nx">fieldParsers</span><span class="p">[</span><span class="nx">j</span><span class="p">].</span><span class="nx">parser</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">rec</span><span class="p">[</span><span class="nx">p</span><span class="p">]);</span>
                            <span class="k">if</span> <span class="p">(</span><span class="nx">rec</span><span class="p">[</span><span class="nx">p</span><span class="p">]</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
                                <span class="nx">rec</span><span class="p">[</span><span class="nx">p</span><span class="p">]</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
                            <span class="p">}</span>
                        <span class="p">}</span>
                    <span class="p">}</span>
                    <span class="nx">results</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">rec</span><span class="p">;</span>
                <span class="p">}</span>
            <span class="p">}</span>
            <span class="k">else</span> <span class="p">{</span>
                <span class="nx">results</span> <span class="o">=</span> <span class="nx">resultsList</span><span class="p">;</span>
            <span class="p">}</span>

            <span class="k">for</span> <span class="p">(</span><span class="nx">key</span> <span class="k">in</span> <span class="nx">metaFields</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">metaFields</span><span class="p">,</span><span class="nx">key</span><span class="p">))</span> <span class="p">{</span>
                    <span class="nx">path</span> <span class="o">=</span> <span class="nx">buildPath</span><span class="p">(</span><span class="nx">metaFields</span><span class="p">[</span><span class="nx">key</span><span class="p">]);</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">path</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">v</span> <span class="o">=</span> <span class="nx">walkPath</span><span class="p">(</span><span class="nx">path</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">);</span>
                        <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">meta</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">v</span><span class="p">;</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>

        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
            <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;JSON data could not be parsed due to invalid responseSchema.resultsList or invalid response: &quot;</span> <span class="o">+</span>
                    <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">),</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>

            <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">error</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">results</span> <span class="o">=</span> <span class="nx">results</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;JSON data could not be parsed: &quot;</span> <span class="o">+</span>
                <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">),</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">error</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="k">return</span> <span class="nx">oParsedResponse</span><span class="p">;</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Overridable method parses an HTML TABLE element reference into a response object.</span>
<span class="cm"> * Data is parsed out of TR elements from all TBODY elements. </span>
<span class="cm"> *</span>
<span class="cm"> * @method parseHTMLTableData</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oFullResponse {Object} The full HTML element reference from the live database.</span>
<span class="cm"> * @return {Object} Parsed response object with the following properties&lt;br&gt;</span>
<span class="cm"> *     - results (Array) Array of parsed data results&lt;br&gt;</span>
<span class="cm"> *     - error (Boolean) True if there was an error</span>
<span class="cm"> */</span>
<span class="nx">parseHTMLTableData</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oFullResponse</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">bError</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
    <span class="kd">var</span> <span class="nx">elTable</span> <span class="o">=</span> <span class="nx">oFullResponse</span><span class="p">;</span>
    <span class="kd">var</span> <span class="nx">fields</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">responseSchema</span><span class="p">.</span><span class="nx">fields</span><span class="p">;</span>
    <span class="kd">var</span> <span class="nx">oParsedResponse</span> <span class="o">=</span> <span class="p">{</span><span class="nx">results</span><span class="o">:</span><span class="p">[]};</span>

    <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">fields</span><span class="p">))</span> <span class="p">{</span>
        <span class="c1">// Iterate through each TBODY</span>
        <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">elTable</span><span class="p">.</span><span class="nx">tBodies</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
            <span class="kd">var</span> <span class="nx">elTbody</span> <span class="o">=</span> <span class="nx">elTable</span><span class="p">.</span><span class="nx">tBodies</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
    
            <span class="c1">// Iterate through each TR</span>
            <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">j</span><span class="o">=</span><span class="nx">elTbody</span><span class="p">.</span><span class="nx">rows</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">j</span><span class="o">&gt;-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">j</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
                <span class="kd">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="nx">elTbody</span><span class="p">.</span><span class="nx">rows</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span>
                <span class="kd">var</span> <span class="nx">oResult</span> <span class="o">=</span> <span class="p">{};</span>
                
                <span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">k</span><span class="o">=</span><span class="nx">fields</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">k</span><span class="o">&gt;-</span><span class="mi">1</span><span class="p">;</span> <span class="nx">k</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
                    <span class="kd">var</span> <span class="nx">field</span> <span class="o">=</span> <span class="nx">fields</span><span class="p">[</span><span class="nx">k</span><span class="p">];</span>
                    <span class="kd">var</span> <span class="nx">key</span> <span class="o">=</span> <span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">field</span><span class="p">.</span><span class="nx">key</span><span class="p">))</span> <span class="o">?</span> <span class="nx">field</span><span class="p">.</span><span class="nx">key</span> <span class="o">:</span> <span class="nx">field</span><span class="p">;</span>
                    <span class="kd">var</span> <span class="nx">data</span> <span class="o">=</span> <span class="nx">elRow</span><span class="p">.</span><span class="nx">cells</span><span class="p">[</span><span class="nx">k</span><span class="p">].</span><span class="nx">innerHTML</span><span class="p">;</span>
    
                    <span class="c1">// Backward compatibility</span>
                    <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">&amp;&amp;</span> <span class="nx">field</span><span class="p">.</span><span class="nx">converter</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">=</span> <span class="nx">field</span><span class="p">.</span><span class="nx">converter</span><span class="p">;</span>
                        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;The field property converter has been deprecated&quot;</span> <span class="o">+</span>
                                <span class="s2">&quot; in favor of parser&quot;</span><span class="p">,</span> <span class="s2">&quot;warn&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
                    <span class="p">}</span>
                    <span class="kd">var</span> <span class="nx">parser</span> <span class="o">=</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">===</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="o">?</span>
                        <span class="nx">field</span><span class="p">.</span><span class="nx">parser</span> <span class="o">:</span>
                        <span class="nx">DS</span><span class="p">.</span><span class="nx">Parser</span><span class="p">[</span><span class="nx">field</span><span class="p">.</span><span class="nx">parser</span><span class="o">+</span><span class="s1">&#39;&#39;</span><span class="p">];</span>
                    <span class="k">if</span><span class="p">(</span><span class="nx">parser</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">data</span> <span class="o">=</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">data</span><span class="p">);</span>
                    <span class="p">}</span>
                    <span class="c1">// Safety measure</span>
                    <span class="k">if</span><span class="p">(</span><span class="nx">data</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">data</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
                    <span class="p">}</span>
                    <span class="nx">oResult</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">data</span><span class="p">;</span>
                <span class="p">}</span>
                <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">results</span><span class="p">[</span><span class="nx">j</span><span class="p">]</span> <span class="o">=</span> <span class="nx">oResult</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nx">bError</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Invalid responseSchema.fields&quot;</span><span class="p">,</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="p">}</span>

    <span class="k">if</span><span class="p">(</span><span class="nx">bError</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;HTML TABLE data could not be parsed: &quot;</span> <span class="o">+</span>
                <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oFullResponse</span><span class="p">),</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="nx">oParsedResponse</span><span class="p">.</span><span class="nx">error</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Parsed HTML TABLE data is &quot;</span> <span class="o">+</span>
                <span class="nx">lang</span><span class="p">.</span><span class="nx">dump</span><span class="p">(</span><span class="nx">oParsedResponse</span><span class="p">),</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="p">}</span>
    <span class="k">return</span> <span class="nx">oParsedResponse</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">};</span>

<span class="c1">// DataSourceBase uses EventProvider</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentProto</span><span class="p">(</span><span class="nx">DS</span><span class="p">,</span> <span class="nx">util</span><span class="p">.</span><span class="nx">EventProvider</span><span class="p">);</span>



<span class="cm">/****************************************************************************/</span>
<span class="cm">/****************************************************************************/</span>
<span class="cm">/****************************************************************************/</span>

<span class="cm">/**</span>
<span class="cm"> * LocalDataSource class for in-memory data structs including JavaScript arrays,</span>
<span class="cm"> * JavaScript object literals (JSON), XML documents, and HTML tables.</span>
<span class="cm"> *</span>
<span class="cm"> * @namespace YAHOO.util</span>
<span class="cm"> * @class YAHOO.util.LocalDataSource</span>
<span class="cm"> * @extends YAHOO.util.DataSourceBase </span>
<span class="cm"> * @constructor</span>
<span class="cm"> * @param oLiveData {HTMLElement}  Pointer to live data.</span>
<span class="cm"> * @param oConfigs {object} (optional) Object literal of configuration values.</span>
<span class="cm"> */</span>
<span class="nx">util</span><span class="p">.</span><span class="nx">LocalDataSource</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">dataType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_LOCAL</span><span class="p">;</span>
    
    <span class="k">if</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// array</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSARRAY</span><span class="p">;</span>
        <span class="p">}</span>
         <span class="c1">// xml</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">.</span><span class="nx">nodeType</span> <span class="o">&amp;&amp;</span> <span class="nx">oLiveData</span><span class="p">.</span><span class="nx">nodeType</span> <span class="o">==</span> <span class="mi">9</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_XML</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">.</span><span class="nx">nodeName</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">oLiveData</span><span class="p">.</span><span class="nx">nodeName</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;table&quot;</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// table</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_HTMLTABLE</span><span class="p">;</span>
            <span class="nx">oLiveData</span> <span class="o">=</span> <span class="nx">oLiveData</span><span class="p">.</span><span class="nx">cloneNode</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
        <span class="p">}</span>    
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// text</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_TEXT</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// json</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSON</span><span class="p">;</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nx">oLiveData</span> <span class="o">=</span> <span class="p">[];</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSARRAY</span><span class="p">;</span>
    <span class="p">}</span>
    
    <span class="nx">util</span><span class="p">.</span><span class="nx">LocalDataSource</span><span class="p">.</span><span class="nx">superclass</span><span class="p">.</span><span class="nx">constructor</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">);</span> 
<span class="p">};</span>

<span class="c1">// LocalDataSource extends DataSourceBase</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span><span class="nx">util</span><span class="p">.</span><span class="nx">LocalDataSource</span><span class="p">,</span> <span class="nx">DS</span><span class="p">);</span>

<span class="c1">// Copy static members to LocalDataSource class</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">util</span><span class="p">.</span><span class="nx">LocalDataSource</span><span class="p">,</span> <span class="nx">DS</span><span class="p">);</span>













<span class="cm">/****************************************************************************/</span>
<span class="cm">/****************************************************************************/</span>
<span class="cm">/****************************************************************************/</span>

<span class="cm">/**</span>
<span class="cm"> * FunctionDataSource class for JavaScript functions.</span>
<span class="cm"> *</span>
<span class="cm"> * @namespace YAHOO.util</span>
<span class="cm"> * @class YAHOO.util.FunctionDataSource</span>
<span class="cm"> * @extends YAHOO.util.DataSourceBase  </span>
<span class="cm"> * @constructor</span>
<span class="cm"> * @param oLiveData {HTMLElement}  Pointer to live data.</span>
<span class="cm"> * @param oConfigs {object} (optional) Object literal of configuration values.</span>
<span class="cm"> */</span>
<span class="nx">util</span><span class="p">.</span><span class="nx">FunctionDataSource</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">dataType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSFUNCTION</span><span class="p">;</span>
    <span class="nx">oLiveData</span> <span class="o">=</span> <span class="nx">oLiveData</span> <span class="o">||</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{};</span>
    
    <span class="nx">util</span><span class="p">.</span><span class="nx">FunctionDataSource</span><span class="p">.</span><span class="nx">superclass</span><span class="p">.</span><span class="nx">constructor</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">);</span> 
<span class="p">};</span>

<span class="c1">// FunctionDataSource extends DataSourceBase</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span><span class="nx">util</span><span class="p">.</span><span class="nx">FunctionDataSource</span><span class="p">,</span> <span class="nx">DS</span><span class="p">,</span> <span class="p">{</span>

<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// FunctionDataSource public properties</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

<span class="cm">/**</span>
<span class="cm"> * Context in which to execute the function. By default, is the DataSource</span>
<span class="cm"> * instance itself. If set, the function will receive the DataSource instance</span>
<span class="cm"> * as an additional argument. </span>
<span class="cm"> *</span>
<span class="cm"> * @property scope</span>
<span class="cm"> * @type Object</span>
<span class="cm"> * @default null</span>
<span class="cm"> */</span>
<span class="nx">scope</span> <span class="o">:</span> <span class="kc">null</span><span class="p">,</span>


<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// FunctionDataSource public methods</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

<span class="cm">/**</span>
<span class="cm"> * Overriding method passes query to a function. The returned response is then</span>
<span class="cm"> * forwarded to the handleResponse function.</span>
<span class="cm"> *</span>
<span class="cm"> * @method makeConnection</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oCallback {Object} Callback object literal.</span>
<span class="cm"> * @param oCaller {Object} (deprecated) Use oCallback.scope.</span>
<span class="cm"> * @return {Number} Transaction ID.</span>
<span class="cm"> */</span>
<span class="nx">makeConnection</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">tId</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">_nTransactionId</span><span class="o">++</span><span class="p">;</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;requestEvent&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">tId</span><span class="o">:</span><span class="nx">tId</span><span class="p">,</span><span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span><span class="nx">callback</span><span class="o">:</span><span class="nx">oCallback</span><span class="p">,</span><span class="nx">caller</span><span class="o">:</span><span class="nx">oCaller</span><span class="p">});</span>

    <span class="c1">// Pass the request in as a parameter and</span>
    <span class="c1">// forward the return value to the handler</span>
    
    
    <span class="kd">var</span> <span class="nx">oRawResponse</span> <span class="o">=</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">scope</span><span class="p">)</span> <span class="o">?</span> <span class="k">this</span><span class="p">.</span><span class="nx">liveData</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">scope</span><span class="p">,</span> <span class="nx">oRequest</span><span class="p">,</span> <span class="k">this</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">)</span> <span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">liveData</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">);</span>
    
    <span class="c1">// Try to sniff data type if it has not been defined</span>
    <span class="k">if</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">===</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_UNKNOWN</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// array</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSARRAY</span><span class="p">;</span>
        <span class="p">}</span>
         <span class="c1">// xml</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">oRawResponse</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeType</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeType</span> <span class="o">==</span> <span class="mi">9</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_XML</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">oRawResponse</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeName</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeName</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;table&quot;</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// table</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_HTMLTABLE</span><span class="p">;</span>
        <span class="p">}</span>    
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// json</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSON</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// text</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_TEXT</span><span class="p">;</span>
        <span class="p">}</span>
    <span class="p">}</span>

    <span class="k">this</span><span class="p">.</span><span class="nx">handleResponse</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oRawResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">,</span> <span class="nx">tId</span><span class="p">);</span>
    <span class="k">return</span> <span class="nx">tId</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">});</span>

<span class="c1">// Copy static members to FunctionDataSource class</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">util</span><span class="p">.</span><span class="nx">FunctionDataSource</span><span class="p">,</span> <span class="nx">DS</span><span class="p">);</span>













<span class="cm">/****************************************************************************/</span>
<span class="cm">/****************************************************************************/</span>
<span class="cm">/****************************************************************************/</span>

<span class="cm">/**</span>
<span class="cm"> * ScriptNodeDataSource class for accessing remote data via the YUI Get Utility. </span>
<span class="cm"> *</span>
<span class="cm"> * @namespace YAHOO.util</span>
<span class="cm"> * @class YAHOO.util.ScriptNodeDataSource</span>
<span class="cm"> * @extends YAHOO.util.DataSourceBase  </span>
<span class="cm"> * @constructor</span>
<span class="cm"> * @param oLiveData {HTMLElement}  Pointer to live data.</span>
<span class="cm"> * @param oConfigs {object} (optional) Object literal of configuration values.</span>
<span class="cm"> */</span>
<span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">dataType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_SCRIPTNODE</span><span class="p">;</span>
    <span class="nx">oLiveData</span> <span class="o">=</span> <span class="nx">oLiveData</span> <span class="o">||</span> <span class="s2">&quot;&quot;</span><span class="p">;</span>
    
    <span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">.</span><span class="nx">superclass</span><span class="p">.</span><span class="nx">constructor</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">);</span> 
<span class="p">};</span>

<span class="c1">// ScriptNodeDataSource extends DataSourceBase</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span><span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">,</span> <span class="nx">DS</span><span class="p">,</span> <span class="p">{</span>

<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// ScriptNodeDataSource public properties</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

<span class="cm">/**</span>
<span class="cm"> * Alias to YUI Get Utility, to allow implementers to use a custom class.</span>
<span class="cm"> *</span>
<span class="cm"> * @property getUtility</span>
<span class="cm"> * @type Object</span>
<span class="cm"> * @default YAHOO.util.Get</span>
<span class="cm"> */</span>
<span class="nx">getUtility</span> <span class="o">:</span> <span class="nx">util</span><span class="p">.</span><span class="nx">Get</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Defines request/response management in the following manner:</span>
<span class="cm"> * &lt;dl&gt;</span>
<span class="cm"> *     &lt;!--&lt;dt&gt;queueRequests&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;If a request is already in progress, wait until response is returned before sending the next request.&lt;/dd&gt;</span>
<span class="cm"> *     &lt;dt&gt;cancelStaleRequests&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;If a request is already in progress, cancel it before sending the next request.&lt;/dd&gt;--&gt;</span>
<span class="cm"> *     &lt;dt&gt;ignoreStaleResponses&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;Send all requests, but handle only the response for the most recently sent request.&lt;/dd&gt;</span>
<span class="cm"> *     &lt;dt&gt;allowAll&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;Send all requests and handle all responses.&lt;/dd&gt;</span>
<span class="cm"> * &lt;/dl&gt;</span>
<span class="cm"> *</span>
<span class="cm"> * @property asyncMode</span>
<span class="cm"> * @type String</span>
<span class="cm"> * @default &quot;allowAll&quot;</span>
<span class="cm"> */</span>
<span class="nx">asyncMode</span> <span class="o">:</span> <span class="s2">&quot;allowAll&quot;</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Callback string parameter name sent to the remote script. By default,</span>
<span class="cm"> * requests are sent to</span>
<span class="cm"> * &amp;#60;URI&amp;#62;?&amp;#60;scriptCallbackParam&amp;#62;=callback</span>
<span class="cm"> *</span>
<span class="cm"> * @property scriptCallbackParam</span>
<span class="cm"> * @type String</span>
<span class="cm"> * @default &quot;callback&quot;</span>
<span class="cm"> */</span>
<span class="nx">scriptCallbackParam</span> <span class="o">:</span> <span class="s2">&quot;callback&quot;</span><span class="p">,</span>


<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// ScriptNodeDataSource public methods</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

<span class="cm">/**</span>
<span class="cm"> * Creates a request callback that gets appended to the script URI. Implementers</span>
<span class="cm"> * can customize this string to match their server&#39;s query syntax.</span>
<span class="cm"> *</span>
<span class="cm"> * @method generateRequestCallback</span>
<span class="cm"> * @return {String} String fragment that gets appended to script URI that </span>
<span class="cm"> * specifies the callback function </span>
<span class="cm"> */</span>
<span class="nx">generateRequestCallback</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">id</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">return</span> <span class="s2">&quot;&amp;&quot;</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">scriptCallbackParam</span> <span class="o">+</span> <span class="s2">&quot;=YAHOO.util.ScriptNodeDataSource.callbacks[&quot;</span><span class="o">+</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;]&quot;</span> <span class="p">;</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Overridable method gives implementers access to modify the URI before the dynamic</span>
<span class="cm"> * script node gets inserted. Implementers should take care not to return an</span>
<span class="cm"> * invalid URI.</span>
<span class="cm"> *</span>
<span class="cm"> * @method doBeforeGetScriptNode</span>
<span class="cm"> * @param {String} URI to the script </span>
<span class="cm"> * @return {String} URI to the script</span>
<span class="cm"> */</span>
<span class="nx">doBeforeGetScriptNode</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">sUri</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">return</span> <span class="nx">sUri</span><span class="p">;</span>
<span class="p">},</span>

<span class="cm">/**</span>
<span class="cm"> * Overriding method passes query to Get Utility. The returned</span>
<span class="cm"> * response is then forwarded to the handleResponse function.</span>
<span class="cm"> *</span>
<span class="cm"> * @method makeConnection</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oCallback {Object} Callback object literal.</span>
<span class="cm"> * @param oCaller {Object} (deprecated) Use oCallback.scope.</span>
<span class="cm"> * @return {Number} Transaction ID.</span>
<span class="cm"> */</span>
<span class="nx">makeConnection</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">tId</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">_nTransactionId</span><span class="o">++</span><span class="p">;</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;requestEvent&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">tId</span><span class="o">:</span><span class="nx">tId</span><span class="p">,</span><span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span><span class="nx">callback</span><span class="o">:</span><span class="nx">oCallback</span><span class="p">,</span><span class="nx">caller</span><span class="o">:</span><span class="nx">oCaller</span><span class="p">});</span>
    
    <span class="c1">// If there are no global pending requests, it is safe to purge global callback stack and global counter</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">.</span><span class="nx">_nPending</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">.</span><span class="nx">callbacks</span> <span class="o">=</span> <span class="p">[];</span>
        <span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">.</span><span class="nx">_nId</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
    <span class="p">}</span>
    
    <span class="c1">// ID for this request</span>
    <span class="kd">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">.</span><span class="nx">_nId</span><span class="p">;</span>
    <span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">.</span><span class="nx">_nId</span><span class="o">++</span><span class="p">;</span>
    
    <span class="c1">// Dynamically add handler function with a closure to the callback stack</span>
    <span class="kd">var</span> <span class="nx">oSelf</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
    <span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">.</span><span class="nx">callbacks</span><span class="p">[</span><span class="nx">id</span><span class="p">]</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span><span class="p">((</span><span class="nx">oSelf</span><span class="p">.</span><span class="nx">asyncMode</span> <span class="o">!==</span> <span class="s2">&quot;ignoreStaleResponses&quot;</span><span class="p">)</span><span class="o">||</span>
                <span class="p">(</span><span class="nx">id</span> <span class="o">===</span> <span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">.</span><span class="nx">callbacks</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// Must ignore stale responses</span>
                
            <span class="c1">// Try to sniff data type if it has not been defined</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">oSelf</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">===</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_UNKNOWN</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// array</span>
                    <span class="nx">oSelf</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSARRAY</span><span class="p">;</span>
                <span class="p">}</span>
                 <span class="c1">// xml</span>
                <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeType</span> <span class="o">&amp;&amp;</span> <span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeType</span> <span class="o">==</span> <span class="mi">9</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">oSelf</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_XML</span><span class="p">;</span>
                <span class="p">}</span>
                <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeName</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">oRawResponse</span><span class="p">.</span><span class="nx">nodeName</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;table&quot;</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// table</span>
                    <span class="nx">oSelf</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_HTMLTABLE</span><span class="p">;</span>
                <span class="p">}</span>    
                <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isObject</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// json</span>
                    <span class="nx">oSelf</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSON</span><span class="p">;</span>
                <span class="p">}</span>
                <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">oRawResponse</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// text</span>
                    <span class="nx">oSelf</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_TEXT</span><span class="p">;</span>
                <span class="p">}</span>
            <span class="p">}</span>

            <span class="nx">oSelf</span><span class="p">.</span><span class="nx">handleResponse</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oRawResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">,</span> <span class="nx">tId</span><span class="p">);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;DataSource ignored stale response for tId &quot;</span> <span class="o">+</span> <span class="nx">tId</span> <span class="o">+</span> <span class="s2">&quot;(&quot;</span> <span class="o">+</span> <span class="nx">oRequest</span> <span class="o">+</span> <span class="s2">&quot;)&quot;</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="nx">oSelf</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="p">}</span>
    
        <span class="k">delete</span> <span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">.</span><span class="nx">callbacks</span><span class="p">[</span><span class="nx">id</span><span class="p">];</span>
    <span class="p">};</span>
    
    <span class="c1">// We are now creating a request</span>
    <span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">.</span><span class="nx">_nPending</span><span class="o">++</span><span class="p">;</span>
    <span class="kd">var</span> <span class="nx">sUri</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">liveData</span> <span class="o">+</span> <span class="nx">oRequest</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">generateRequestCallback</span><span class="p">(</span><span class="nx">id</span><span class="p">);</span>
    <span class="nx">sUri</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">doBeforeGetScriptNode</span><span class="p">(</span><span class="nx">sUri</span><span class="p">);</span>
    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;DataSource is querying URL &quot;</span> <span class="o">+</span> <span class="nx">sUri</span><span class="p">,</span> <span class="s2">&quot;info&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">getUtility</span><span class="p">.</span><span class="nx">script</span><span class="p">(</span><span class="nx">sUri</span><span class="p">,</span>
            <span class="p">{</span><span class="nx">autopurge</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
            <span class="nx">onsuccess</span><span class="o">:</span> <span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">.</span><span class="nx">_bumpPendingDown</span><span class="p">,</span>
            <span class="nx">onfail</span><span class="o">:</span> <span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">.</span><span class="nx">_bumpPendingDown</span><span class="p">});</span>

    <span class="k">return</span> <span class="nx">tId</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">});</span>

<span class="c1">// Copy static members to ScriptNodeDataSource class</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">,</span> <span class="nx">DS</span><span class="p">);</span>

<span class="c1">// Copy static members to ScriptNodeDataSource class</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">,</span>  <span class="p">{</span>

<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// ScriptNodeDataSource private static properties</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

<span class="cm">/**</span>
<span class="cm"> * Unique ID to track requests.</span>
<span class="cm"> *</span>
<span class="cm"> * @property _nId</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @private</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">_nId</span> <span class="o">:</span> <span class="mi">0</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Counter for pending requests. When this is 0, it is safe to purge callbacks</span>
<span class="cm"> * array.</span>
<span class="cm"> *</span>
<span class="cm"> * @property _nPending</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @private</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">_nPending</span> <span class="o">:</span> <span class="mi">0</span><span class="p">,</span>

<span class="cm">/**</span>
<span class="cm"> * Global array of callback functions, one for each request sent.</span>
<span class="cm"> *</span>
<span class="cm"> * @property callbacks</span>
<span class="cm"> * @type Function[]</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>
<span class="nx">callbacks</span> <span class="o">:</span> <span class="p">[]</span>

<span class="p">});</span>














<span class="cm">/****************************************************************************/</span>
<span class="cm">/****************************************************************************/</span>
<span class="cm">/****************************************************************************/</span>

<span class="cm">/**</span>
<span class="cm"> * XHRDataSource class for accessing remote data via the YUI Connection Manager</span>
<span class="cm"> * Utility</span>
<span class="cm"> *</span>
<span class="cm"> * @namespace YAHOO.util</span>
<span class="cm"> * @class YAHOO.util.XHRDataSource</span>
<span class="cm"> * @extends YAHOO.util.DataSourceBase  </span>
<span class="cm"> * @constructor</span>
<span class="cm"> * @param oLiveData {HTMLElement}  Pointer to live data.</span>
<span class="cm"> * @param oConfigs {object} (optional) Object literal of configuration values.</span>
<span class="cm"> */</span>
<span class="nx">util</span><span class="p">.</span><span class="nx">XHRDataSource</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">dataType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_XHR</span><span class="p">;</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">connMgr</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">connMgr</span> <span class="o">||</span> <span class="nx">util</span><span class="p">.</span><span class="nx">Connect</span><span class="p">;</span>
    <span class="nx">oLiveData</span> <span class="o">=</span> <span class="nx">oLiveData</span> <span class="o">||</span> <span class="s2">&quot;&quot;</span><span class="p">;</span>
    
    <span class="nx">util</span><span class="p">.</span><span class="nx">XHRDataSource</span><span class="p">.</span><span class="nx">superclass</span><span class="p">.</span><span class="nx">constructor</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">);</span> 
<span class="p">};</span>

<span class="c1">// XHRDataSource extends DataSourceBase</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span><span class="nx">util</span><span class="p">.</span><span class="nx">XHRDataSource</span><span class="p">,</span> <span class="nx">DS</span><span class="p">,</span> <span class="p">{</span>

<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// XHRDataSource public properties</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

 <span class="cm">/**</span>
<span class="cm"> * Alias to YUI Connection Manager, to allow implementers to use a custom class.</span>
<span class="cm"> *</span>
<span class="cm"> * @property connMgr</span>
<span class="cm"> * @type Object</span>
<span class="cm"> * @default YAHOO.util.Connect</span>
<span class="cm"> */</span>
<span class="nx">connMgr</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>

 <span class="cm">/**</span>
<span class="cm"> * Defines request/response management in the following manner:</span>
<span class="cm"> * &lt;dl&gt;</span>
<span class="cm"> *     &lt;dt&gt;queueRequests&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;If a request is already in progress, wait until response is returned</span>
<span class="cm"> *     before sending the next request.&lt;/dd&gt;</span>
<span class="cm"> *</span>
<span class="cm"> *     &lt;dt&gt;cancelStaleRequests&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;If a request is already in progress, cancel it before sending the next</span>
<span class="cm"> *     request.&lt;/dd&gt;</span>
<span class="cm"> *</span>
<span class="cm"> *     &lt;dt&gt;ignoreStaleResponses&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;Send all requests, but handle only the response for the most recently</span>
<span class="cm"> *     sent request.&lt;/dd&gt;</span>
<span class="cm"> *</span>
<span class="cm"> *     &lt;dt&gt;allowAll&lt;/dt&gt;</span>
<span class="cm"> *     &lt;dd&gt;Send all requests and handle all responses.&lt;/dd&gt;</span>
<span class="cm"> *</span>
<span class="cm"> * &lt;/dl&gt;</span>
<span class="cm"> *</span>
<span class="cm"> * @property connXhrMode</span>
<span class="cm"> * @type String</span>
<span class="cm"> * @default &quot;allowAll&quot;</span>
<span class="cm"> */</span>
<span class="nx">connXhrMode</span><span class="o">:</span> <span class="s2">&quot;allowAll&quot;</span><span class="p">,</span>

 <span class="cm">/**</span>
<span class="cm"> * True if data is to be sent via POST. By default, data will be sent via GET.</span>
<span class="cm"> *</span>
<span class="cm"> * @property connMethodPost</span>
<span class="cm"> * @type Boolean</span>
<span class="cm"> * @default false</span>
<span class="cm"> */</span>
<span class="nx">connMethodPost</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>

 <span class="cm">/**</span>
<span class="cm"> * The connection timeout defines how many  milliseconds the XHR connection will</span>
<span class="cm"> * wait for a server response. Any non-zero value will enable the Connection Manager&#39;s</span>
<span class="cm"> * Auto-Abort feature.</span>
<span class="cm"> *</span>
<span class="cm"> * @property connTimeout</span>
<span class="cm"> * @type Number</span>
<span class="cm"> * @default 0</span>
<span class="cm"> */</span>
<span class="nx">connTimeout</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span>

<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c1">//</span>
<span class="c1">// XHRDataSource public methods</span>
<span class="c1">//</span>
<span class="c1">/////////////////////////////////////////////////////////////////////////////</span>

<span class="cm">/**</span>
<span class="cm"> * Overriding method passes query to Connection Manager. The returned</span>
<span class="cm"> * response is then forwarded to the handleResponse function.</span>
<span class="cm"> *</span>
<span class="cm"> * @method makeConnection</span>
<span class="cm"> * @param oRequest {Object} Request object.</span>
<span class="cm"> * @param oCallback {Object} Callback object literal.</span>
<span class="cm"> * @param oCaller {Object} (deprecated) Use oCallback.scope.</span>
<span class="cm"> * @return {Number} Transaction ID.</span>
<span class="cm"> */</span>
<span class="nx">makeConnection</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">)</span> <span class="p">{</span>

    <span class="kd">var</span> <span class="nx">oRawResponse</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
    <span class="kd">var</span> <span class="nx">tId</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">_nTransactionId</span><span class="o">++</span><span class="p">;</span>
    <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;requestEvent&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">tId</span><span class="o">:</span><span class="nx">tId</span><span class="p">,</span><span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span><span class="nx">callback</span><span class="o">:</span><span class="nx">oCallback</span><span class="p">,</span><span class="nx">caller</span><span class="o">:</span><span class="nx">oCaller</span><span class="p">});</span>

    <span class="c1">// Set up the callback object and</span>
    <span class="c1">// pass the request in as a URL query and</span>
    <span class="c1">// forward the response to the handler</span>
    <span class="kd">var</span> <span class="nx">oSelf</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
    <span class="kd">var</span> <span class="nx">oConnMgr</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">connMgr</span><span class="p">;</span>
    <span class="kd">var</span> <span class="nx">oQueue</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_oQueue</span><span class="p">;</span>

    <span class="cm">/**</span>
<span class="cm">     * Define Connection Manager success handler</span>
<span class="cm">     *</span>
<span class="cm">     * @method _xhrSuccess</span>
<span class="cm">     * @param oResponse {Object} HTTPXMLRequest object</span>
<span class="cm">     * @private</span>
<span class="cm">     */</span>
    <span class="kd">var</span> <span class="nx">_xhrSuccess</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oResponse</span><span class="p">)</span> <span class="p">{</span>
        <span class="c1">// If response ID does not match last made request ID,</span>
        <span class="c1">// silently fail and wait for the next response</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">oResponse</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">connXhrMode</span> <span class="o">==</span> <span class="s2">&quot;ignoreStaleResponses&quot;</span><span class="p">)</span> <span class="o">&amp;&amp;</span>
                <span class="p">(</span><span class="nx">oResponse</span><span class="p">.</span><span class="nx">tId</span> <span class="o">!=</span> <span class="nx">oQueue</span><span class="p">.</span><span class="nx">conn</span><span class="p">.</span><span class="nx">tId</span><span class="p">))</span> <span class="p">{</span>
            <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Ignored stale response&quot;</span><span class="p">,</span> <span class="s2">&quot;warn&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
            <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="c1">// Error if no response</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">oResponse</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;dataErrorEvent&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">response</span><span class="o">:</span><span class="kc">null</span><span class="p">,</span>
                    <span class="nx">callback</span><span class="o">:</span><span class="nx">oCallback</span><span class="p">,</span> <span class="nx">caller</span><span class="o">:</span><span class="nx">oCaller</span><span class="p">,</span>
                    <span class="nx">message</span><span class="o">:</span><span class="nx">DS</span><span class="p">.</span><span class="nx">ERROR_DATANULL</span><span class="p">});</span>
            <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">DS</span><span class="p">.</span><span class="nx">ERROR_DATANULL</span><span class="p">,</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>

            <span class="c1">// Send error response back to the caller with the error flag on</span>
            <span class="nx">DS</span><span class="p">.</span><span class="nx">issueCallback</span><span class="p">(</span><span class="nx">oCallback</span><span class="p">,[</span><span class="nx">oRequest</span><span class="p">,</span> <span class="p">{</span><span class="nx">error</span><span class="o">:</span><span class="kc">true</span><span class="p">}],</span> <span class="kc">true</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">);</span>

            <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="c1">// Forward to handler</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="c1">// Try to sniff data type if it has not been defined</span>
            <span class="k">if</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">===</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_UNKNOWN</span><span class="p">)</span> <span class="p">{</span>
                <span class="kd">var</span> <span class="nx">ctype</span> <span class="o">=</span> <span class="p">(</span><span class="nx">oResponse</span><span class="p">.</span><span class="nx">getResponseHeader</span><span class="p">)</span> <span class="o">?</span> <span class="nx">oResponse</span><span class="p">.</span><span class="nx">getResponseHeader</span><span class="p">[</span><span class="s2">&quot;Content-Type&quot;</span><span class="p">]</span> <span class="o">:</span> <span class="kc">null</span><span class="p">;</span>
                <span class="k">if</span><span class="p">(</span><span class="nx">ctype</span><span class="p">)</span> <span class="p">{</span>
                    <span class="c1">// xml</span>
                    <span class="k">if</span><span class="p">(</span><span class="nx">ctype</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s2">&quot;text/xml&quot;</span><span class="p">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_XML</span><span class="p">;</span>
                    <span class="p">}</span>
                    <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">ctype</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s2">&quot;application/json&quot;</span><span class="p">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// json</span>
                        <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSON</span><span class="p">;</span>
                    <span class="p">}</span>
                    <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">ctype</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s2">&quot;text/plain&quot;</span><span class="p">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// text</span>
                        <span class="k">this</span><span class="p">.</span><span class="nx">responseType</span> <span class="o">=</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_TEXT</span><span class="p">;</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">handleResponse</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">oResponse</span><span class="p">,</span> <span class="nx">oCallback</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">,</span> <span class="nx">tId</span><span class="p">);</span>
        <span class="p">}</span>
    <span class="p">};</span>

    <span class="cm">/**</span>
<span class="cm">     * Define Connection Manager failure handler</span>
<span class="cm">     *</span>
<span class="cm">     * @method _xhrFailure</span>
<span class="cm">     * @param oResponse {Object} HTTPXMLRequest object</span>
<span class="cm">     * @private</span>
<span class="cm">     */</span>
    <span class="kd">var</span> <span class="nx">_xhrFailure</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oResponse</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;dataErrorEvent&quot;</span><span class="p">,</span> <span class="p">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">response</span><span class="o">:</span> <span class="nx">oResponse</span><span class="p">,</span>
                <span class="nx">callback</span><span class="o">:</span><span class="nx">oCallback</span><span class="p">,</span> <span class="nx">caller</span><span class="o">:</span><span class="nx">oCaller</span><span class="p">,</span>
                <span class="nx">message</span><span class="o">:</span><span class="nx">DS</span><span class="p">.</span><span class="nx">ERROR_DATAINVALID</span><span class="p">});</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">DS</span><span class="p">.</span><span class="nx">ERROR_DATAINVALID</span> <span class="o">+</span> <span class="s2">&quot;: &quot;</span> <span class="o">+</span>
                <span class="nx">oResponse</span><span class="p">.</span><span class="nx">statusText</span><span class="p">,</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>

        <span class="c1">// Backward compatibility</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">liveData</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">)</span> <span class="o">&amp;&amp;</span>
            <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">liveData</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s2">&quot;?&quot;</span><span class="p">)</span> <span class="o">!==</span> <span class="k">this</span><span class="p">.</span><span class="nx">liveData</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="o">&amp;&amp;</span>
            <span class="p">(</span><span class="nx">oRequest</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s2">&quot;?&quot;</span><span class="p">)</span> <span class="o">!==</span> <span class="mi">0</span><span class="p">)){</span>
                <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;DataSources using XHR no longer automatically supply &quot;</span> <span class="o">+</span> 
                <span class="s2">&quot;a \&quot;?\&quot; between the host and query parameters&quot;</span> <span class="o">+</span>
                <span class="s2">&quot; -- please check that the request URL is correct&quot;</span><span class="p">,</span> <span class="s2">&quot;warn&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="p">}</span>

        <span class="c1">// Send failure response back to the caller with the error flag on</span>
        <span class="nx">oResponse</span> <span class="o">=</span> <span class="nx">oResponse</span> <span class="o">||</span> <span class="p">{};</span>
        <span class="nx">oResponse</span><span class="p">.</span><span class="nx">error</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
        <span class="nx">DS</span><span class="p">.</span><span class="nx">issueCallback</span><span class="p">(</span><span class="nx">oCallback</span><span class="p">,[</span><span class="nx">oRequest</span><span class="p">,</span><span class="nx">oResponse</span><span class="p">],</span><span class="kc">true</span><span class="p">,</span> <span class="nx">oCaller</span><span class="p">);</span>

        <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
    <span class="p">};</span>

    <span class="cm">/**</span>
<span class="cm">     * Define Connection Manager callback object</span>
<span class="cm">     *</span>
<span class="cm">     * @property _xhrCallback</span>
<span class="cm">     * @param oResponse {Object} HTTPXMLRequest object</span>
<span class="cm">     * @private</span>
<span class="cm">     */</span>
     <span class="kd">var</span> <span class="nx">_xhrCallback</span> <span class="o">=</span> <span class="p">{</span>
        <span class="nx">success</span><span class="o">:</span><span class="nx">_xhrSuccess</span><span class="p">,</span>
        <span class="nx">failure</span><span class="o">:</span><span class="nx">_xhrFailure</span><span class="p">,</span>
        <span class="nx">scope</span><span class="o">:</span> <span class="k">this</span>
    <span class="p">};</span>

    <span class="c1">// Apply Connection Manager timeout</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isNumber</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">connTimeout</span><span class="p">))</span> <span class="p">{</span>
        <span class="nx">_xhrCallback</span><span class="p">.</span><span class="nx">timeout</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">connTimeout</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="c1">// Cancel stale requests</span>
    <span class="k">if</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">connXhrMode</span> <span class="o">==</span> <span class="s2">&quot;cancelStaleRequests&quot;</span><span class="p">)</span> <span class="p">{</span>
            <span class="c1">// Look in queue for stale requests</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">oQueue</span><span class="p">.</span><span class="nx">conn</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span><span class="p">(</span><span class="nx">oConnMgr</span><span class="p">.</span><span class="nx">abort</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">oConnMgr</span><span class="p">.</span><span class="nx">abort</span><span class="p">(</span><span class="nx">oQueue</span><span class="p">.</span><span class="nx">conn</span><span class="p">);</span>
                    <span class="nx">oQueue</span><span class="p">.</span><span class="nx">conn</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
                    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Canceled stale request&quot;</span><span class="p">,</span> <span class="s2">&quot;warn&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
                <span class="p">}</span>
                <span class="k">else</span> <span class="p">{</span>
                    <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Could not find Connection Manager abort() function&quot;</span><span class="p">,</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
                <span class="p">}</span>
            <span class="p">}</span>
    <span class="p">}</span>

    <span class="c1">// Get ready to send the request URL</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">oConnMgr</span> <span class="o">&amp;&amp;</span> <span class="nx">oConnMgr</span><span class="p">.</span><span class="nx">asyncRequest</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">sLiveData</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">liveData</span><span class="p">;</span>
        <span class="kd">var</span> <span class="nx">isPost</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">connMethodPost</span><span class="p">;</span>
        <span class="kd">var</span> <span class="nx">sMethod</span> <span class="o">=</span> <span class="p">(</span><span class="nx">isPost</span><span class="p">)</span> <span class="o">?</span> <span class="s2">&quot;POST&quot;</span> <span class="o">:</span> <span class="s2">&quot;GET&quot;</span><span class="p">;</span>
        <span class="c1">// Validate request</span>
        <span class="kd">var</span> <span class="nx">sUri</span> <span class="o">=</span> <span class="p">(</span><span class="nx">isPost</span> <span class="o">||</span> <span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">oRequest</span><span class="p">))</span> <span class="o">?</span> <span class="nx">sLiveData</span> <span class="o">:</span> <span class="nx">sLiveData</span><span class="o">+</span><span class="nx">oRequest</span><span class="p">;</span>
        <span class="kd">var</span> <span class="nx">sRequest</span> <span class="o">=</span> <span class="p">(</span><span class="nx">isPost</span><span class="p">)</span> <span class="o">?</span> <span class="nx">oRequest</span> <span class="o">:</span> <span class="kc">null</span><span class="p">;</span>

        <span class="c1">// Send the request right away</span>
        <span class="k">if</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">connXhrMode</span> <span class="o">!=</span> <span class="s2">&quot;queueRequests&quot;</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">oQueue</span><span class="p">.</span><span class="nx">conn</span> <span class="o">=</span> <span class="nx">oConnMgr</span><span class="p">.</span><span class="nx">asyncRequest</span><span class="p">(</span><span class="nx">sMethod</span><span class="p">,</span> <span class="nx">sUri</span><span class="p">,</span> <span class="nx">_xhrCallback</span><span class="p">,</span> <span class="nx">sRequest</span><span class="p">);</span>
        <span class="p">}</span>
        <span class="c1">// Queue up then send the request</span>
        <span class="k">else</span> <span class="p">{</span>
            <span class="c1">// Found a request already in progress</span>
            <span class="k">if</span><span class="p">(</span><span class="nx">oQueue</span><span class="p">.</span><span class="nx">conn</span><span class="p">)</span> <span class="p">{</span>
                <span class="kd">var</span> <span class="nx">allRequests</span> <span class="o">=</span> <span class="nx">oQueue</span><span class="p">.</span><span class="nx">requests</span><span class="p">;</span>
                <span class="c1">// Add request to queue</span>
                <span class="nx">allRequests</span><span class="p">.</span><span class="nx">push</span><span class="p">({</span><span class="nx">request</span><span class="o">:</span><span class="nx">oRequest</span><span class="p">,</span> <span class="nx">callback</span><span class="o">:</span><span class="nx">_xhrCallback</span><span class="p">});</span>

                <span class="c1">// Interval needs to be started</span>
                <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">oQueue</span><span class="p">.</span><span class="nx">interval</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">oQueue</span><span class="p">.</span><span class="nx">interval</span> <span class="o">=</span> <span class="nx">setInterval</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
                        <span class="c1">// Connection is in progress</span>
                        <span class="k">if</span><span class="p">(</span><span class="nx">oConnMgr</span><span class="p">.</span><span class="nx">isCallInProgress</span><span class="p">(</span><span class="nx">oQueue</span><span class="p">.</span><span class="nx">conn</span><span class="p">))</span> <span class="p">{</span>
                            <span class="k">return</span><span class="p">;</span>
                        <span class="p">}</span>
                        <span class="k">else</span> <span class="p">{</span>
                            <span class="c1">// Send next request</span>
                            <span class="k">if</span><span class="p">(</span><span class="nx">allRequests</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
                                <span class="c1">// Validate request</span>
                                <span class="nx">sUri</span> <span class="o">=</span> <span class="p">(</span><span class="nx">isPost</span> <span class="o">||</span> <span class="o">!</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isValue</span><span class="p">(</span><span class="nx">allRequests</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nx">request</span><span class="p">))</span> <span class="o">?</span> <span class="nx">sLiveData</span> <span class="o">:</span> <span class="nx">sLiveData</span><span class="o">+</span><span class="nx">allRequests</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nx">request</span><span class="p">;</span>
                                <span class="nx">sRequest</span> <span class="o">=</span> <span class="p">(</span><span class="nx">isPost</span><span class="p">)</span> <span class="o">?</span> <span class="nx">allRequests</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nx">request</span> <span class="o">:</span> <span class="kc">null</span><span class="p">;</span>
                                <span class="nx">oQueue</span><span class="p">.</span><span class="nx">conn</span> <span class="o">=</span> <span class="nx">oConnMgr</span><span class="p">.</span><span class="nx">asyncRequest</span><span class="p">(</span><span class="nx">sMethod</span><span class="p">,</span> <span class="nx">sUri</span><span class="p">,</span> <span class="nx">allRequests</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nx">callback</span><span class="p">,</span> <span class="nx">sRequest</span><span class="p">);</span>

                                <span class="c1">// Remove request from queue</span>
                                <span class="nx">allRequests</span><span class="p">.</span><span class="nx">shift</span><span class="p">();</span>
                            <span class="p">}</span>
                            <span class="c1">// No more requests</span>
                            <span class="k">else</span> <span class="p">{</span>
                                <span class="nx">clearInterval</span><span class="p">(</span><span class="nx">oQueue</span><span class="p">.</span><span class="nx">interval</span><span class="p">);</span>
                                <span class="nx">oQueue</span><span class="p">.</span><span class="nx">interval</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
                            <span class="p">}</span>
                        <span class="p">}</span>
                    <span class="p">},</span> <span class="mi">50</span><span class="p">);</span>
                <span class="p">}</span>
            <span class="p">}</span>
            <span class="c1">// Nothing is in progress</span>
            <span class="k">else</span> <span class="p">{</span>
                <span class="nx">oQueue</span><span class="p">.</span><span class="nx">conn</span> <span class="o">=</span> <span class="nx">oConnMgr</span><span class="p">.</span><span class="nx">asyncRequest</span><span class="p">(</span><span class="nx">sMethod</span><span class="p">,</span> <span class="nx">sUri</span><span class="p">,</span> <span class="nx">_xhrCallback</span><span class="p">,</span> <span class="nx">sRequest</span><span class="p">);</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span>
        <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Could not find Connection Manager asyncRequest() function&quot;</span><span class="p">,</span> <span class="s2">&quot;error&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
        <span class="c1">// Send null response back to the caller with the error flag on</span>
        <span class="nx">DS</span><span class="p">.</span><span class="nx">issueCallback</span><span class="p">(</span><span class="nx">oCallback</span><span class="p">,[</span><span class="nx">oRequest</span><span class="p">,{</span><span class="nx">error</span><span class="o">:</span><span class="kc">true</span><span class="p">}],</span><span class="kc">true</span><span class="p">,</span><span class="nx">oCaller</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="k">return</span> <span class="nx">tId</span><span class="p">;</span>
<span class="p">}</span>

<span class="p">});</span>

<span class="c1">// Copy static members to XHRDataSource class</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">util</span><span class="p">.</span><span class="nx">XHRDataSource</span><span class="p">,</span> <span class="nx">DS</span><span class="p">);</span>













<span class="cm">/****************************************************************************/</span>
<span class="cm">/****************************************************************************/</span>
<span class="cm">/****************************************************************************/</span>

<span class="cm">/**</span>
<span class="cm"> * Factory class for creating a BaseDataSource subclass instance. The sublcass is</span>
<span class="cm"> * determined by oLiveData&#39;s type, unless the dataType config is explicitly passed in.  </span>
<span class="cm"> *</span>
<span class="cm"> * @namespace YAHOO.util</span>
<span class="cm"> * @class YAHOO.util.DataSource</span>
<span class="cm"> * @constructor</span>
<span class="cm"> * @param oLiveData {HTMLElement}  Pointer to live data.</span>
<span class="cm"> * @param oConfigs {object} (optional) Object literal of configuration values.</span>
<span class="cm"> */</span>
<span class="nx">util</span><span class="p">.</span><span class="nx">DataSource</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">)</span> <span class="p">{</span>
    <span class="nx">oConfigs</span> <span class="o">=</span> <span class="nx">oConfigs</span> <span class="o">||</span> <span class="p">{};</span>
    
    <span class="c1">// Point to one of the subclasses, first by dataType if given, then by sniffing oLiveData type.</span>
    <span class="kd">var</span> <span class="nx">dataType</span> <span class="o">=</span> <span class="nx">oConfigs</span><span class="p">.</span><span class="nx">dataType</span><span class="p">;</span>
    <span class="k">if</span><span class="p">(</span><span class="nx">dataType</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span><span class="p">(</span><span class="nx">dataType</span> <span class="o">==</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_LOCAL</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="k">new</span> <span class="nx">util</span><span class="p">.</span><span class="nx">LocalDataSource</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">);</span>
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">dataType</span> <span class="o">==</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_XHR</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="k">new</span> <span class="nx">util</span><span class="p">.</span><span class="nx">XHRDataSource</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">);</span>            
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">dataType</span> <span class="o">==</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_SCRIPTNODE</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="k">new</span> <span class="nx">util</span><span class="p">.</span><span class="nx">ScriptNodeDataSource</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">);</span>            
        <span class="p">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">dataType</span> <span class="o">==</span> <span class="nx">DS</span><span class="p">.</span><span class="nx">TYPE_JSFUNCTION</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="k">new</span> <span class="nx">util</span><span class="p">.</span><span class="nx">FunctionDataSource</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">);</span>            
        <span class="p">}</span>
    <span class="p">}</span>
    
    <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">))</span> <span class="p">{</span> <span class="c1">// strings default to xhr</span>
        <span class="k">return</span> <span class="k">new</span> <span class="nx">util</span><span class="p">.</span><span class="nx">XHRDataSource</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">);</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isFunction</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">return</span> <span class="k">new</span> <span class="nx">util</span><span class="p">.</span><span class="nx">FunctionDataSource</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">);</span>
    <span class="p">}</span>
    <span class="k">else</span> <span class="p">{</span> <span class="c1">// ultimate default is local</span>
        <span class="k">return</span> <span class="k">new</span> <span class="nx">util</span><span class="p">.</span><span class="nx">LocalDataSource</span><span class="p">(</span><span class="nx">oLiveData</span><span class="p">,</span> <span class="nx">oConfigs</span><span class="p">);</span>
    <span class="p">}</span>
<span class="p">};</span>

<span class="c1">// Copy static members to DataSource class</span>
<span class="nx">lang</span><span class="p">.</span><span class="nx">augmentObject</span><span class="p">(</span><span class="nx">util</span><span class="p">.</span><span class="nx">DataSource</span><span class="p">,</span> <span class="nx">DS</span><span class="p">);</span>

<span class="p">})();</span>
</pre></div>

                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div id="moduleList" class="module">
                        <h4>Modules</h4>
                        <ul class="content">
                                <li class=""><a href="module_animation.html" title="animation">animation</a></li>
                                <li class=""><a href="module_autocomplete.html" title="autocomplete">autocomplete</a></li>
                                <li class=""><a href="module_button.html" title="button">button</a></li>
                                <li class=""><a href="module_calendar.html" title="calendar">calendar</a></li>
                                <li class=""><a href="module_carousel.html" title="carousel">carousel</a></li>
                                <li class=""><a href="module_charts.html" title="charts">charts</a></li>
                                <li class=""><a href="module_colorpicker.html" title="colorpicker">colorpicker</a></li>
                                <li class=""><a href="module_connection.html" title="connection">connection</a></li>
                                <li class=""><a href="module_container.html" title="container">container</a></li>
                                <li class=""><a href="module_cookie.html" title="cookie">cookie</a></li>
                                <li class="selected"><a href="module_datasource.html" title="datasource">datasource</a></li>
                                <li class=""><a href="module_datatable.html" title="datatable">datatable</a></li>
                                <li class=""><a href="module_datemath.html" title="datemath">datemath</a></li>
                                <li class=""><a href="module_dom.html" title="dom">dom</a></li>
                                <li class=""><a href="module_dragdrop.html" title="dragdrop">dragdrop</a></li>
                                <li class=""><a href="module_editor.html" title="editor">editor</a></li>
                                <li class=""><a href="module_element.html" title="element">element</a></li>
                                <li class=""><a href="module_element-delegate.html" title="element-delegate">element-delegate</a></li>
                                <li class=""><a href="module_event.html" title="event">event</a></li>
                                <li class=""><a href="module_event-delegate.html" title="event-delegate">event-delegate</a></li>
                                <li class=""><a href="module_event-mouseenter.html" title="event-mouseenter">event-mouseenter</a></li>
                                <li class=""><a href="module_event-simulate.html" title="event-simulate">event-simulate</a></li>
                                <li class=""><a href="module_get.html" title="get">get</a></li>
                                <li class=""><a href="module_history.html" title="history">history</a></li>
                                <li class=""><a href="module_imagecropper.html" title="imagecropper">imagecropper</a></li>
                                <li class=""><a href="module_imageloader.html" title="imageloader">imageloader</a></li>
                                <li class=""><a href="module_json.html" title="json">json</a></li>
                                <li class=""><a href="module_layout.html" title="layout">layout</a></li>
                                <li class=""><a href="module_logger.html" title="logger">logger</a></li>
                                <li class=""><a href="module_menu.html" title="menu">menu</a></li>
                                <li class=""><a href="module_paginator.html" title="paginator">paginator</a></li>
                                <li class=""><a href="module_profiler.html" title="profiler">profiler</a></li>
                                <li class=""><a href="module_profilerviewer.html" title="profilerviewer">profilerviewer</a></li>
                                <li class=""><a href="module_progressbar.html" title="progressbar">progressbar</a></li>
                                <li class=""><a href="module_resize.html" title="resize">resize</a></li>
                                <li class=""><a href="module_selector.html" title="selector">selector</a></li>
                                <li class=""><a href="module_slider.html" title="slider">slider</a></li>
                                <li class=""><a href="module_storage.html" title="Storage">Storage</a></li>
                                <li class=""><a href="module_stylesheet.html" title="stylesheet">stylesheet</a></li>
                                <li class=""><a href="module_swf.html" title="swf">swf</a></li>
                                <li class=""><a href="module_swfdetect.html" title="swfdetect">swfdetect</a></li>
                                <li class=""><a href="module_swfstore.html" title="swfstore">swfstore</a></li>
                                <li class=""><a href="module_tabview.html" title="tabview">tabview</a></li>
                                <li class=""><a href="module_treeview.html" title="treeview">treeview</a></li>
                                <li class=""><a href="module_uploader.html" title="uploader">uploader</a></li>
                                <li class=""><a href="module_yahoo.html" title="yahoo">yahoo</a></li>
                                <li class=""><a href="module_yuiloader.html" title="yuiloader">yuiloader</a></li>
                                <li class=""><a href="module_yuitest.html" title="yuitest">yuitest</a></li>
                        </ul>
                    </div>

                    <div id="classList" class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="YAHOO.util.DataSource.html" title="YAHOO.util.DataSource">YAHOO.util.DataSource</a></li>
                                <li class=""><a href="YAHOO.util.DataSourceBase.html" title="YAHOO.util.DataSourceBase">YAHOO.util.DataSourceBase</a></li>
                                <li class=""><a href="YAHOO.util.Date.html" title="YAHOO.util.Date">YAHOO.util.Date</a></li>
                                <li class=""><a href="YAHOO.util.DateLocale.html" title="YAHOO.util.DateLocale">YAHOO.util.DateLocale</a></li>
                                <li class=""><a href="YAHOO.util.FunctionDataSource.html" title="YAHOO.util.FunctionDataSource">YAHOO.util.FunctionDataSource</a></li>
                                <li class=""><a href="YAHOO.util.LocalDataSource.html" title="YAHOO.util.LocalDataSource">YAHOO.util.LocalDataSource</a></li>
                                <li class=""><a href="YAHOO.util.Number.html" title="YAHOO.util.Number">YAHOO.util.Number</a></li>
                                <li class=""><a href="YAHOO.util.ScriptNodeDataSource.html" title="YAHOO.util.ScriptNodeDataSource">YAHOO.util.ScriptNodeDataSource</a></li>
                                <li class=""><a href="YAHOO.util.XHRDataSource.html" title="YAHOO.util.XHRDataSource">YAHOO.util.XHRDataSource</a></li>
                        </ul>
                    </div>

                    <div id="fileList" class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class="selected"><a href="DataSource.js.html" title="DataSource.js">DataSource.js</a></li>
                                <li class=""><a href="Type.js.html" title="Type.js">Type.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2011 Yahoo! Inc. All rights reserved.
	</div>
</div>
<script type="text/javascript">

    var ALL_YUI_PROPS = [{"access": "private", "host": "YAHOO.util.DataSourceBase", "name": "_aCache", "url": "YAHOO.util.DataSourceBase.html#property__aCache", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "addToCache", "url": "YAHOO.util.DataSourceBase.html#method_addToCache", "type": "method"}, {"access": "private", "host": "YAHOO.util.DataSourceBase", "name": "_aIntervals", "url": "YAHOO.util.DataSourceBase.html#property__aIntervals", "type": "property"}, {"access": "", "host": "YAHOO.util.ScriptNodeDataSource", "name": "asyncMode", "url": "YAHOO.util.ScriptNodeDataSource.html#property_asyncMode", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "cacheFlushEvent", "url": "YAHOO.util.DataSourceBase.html#event_cacheFlushEvent", "type": "event"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "cacheRequestEvent", "url": "YAHOO.util.DataSourceBase.html#event_cacheRequestEvent", "type": "event"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "cacheResponseEvent", "url": "YAHOO.util.DataSourceBase.html#event_cacheResponseEvent", "type": "event"}, {"access": "", "host": "YAHOO.util.ScriptNodeDataSource", "name": "callbacks", "url": "YAHOO.util.ScriptNodeDataSource.html#property_callbacks", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "clearAllIntervals", "url": "YAHOO.util.DataSourceBase.html#method_clearAllIntervals", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "clearInterval", "url": "YAHOO.util.DataSourceBase.html#method_clearInterval", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "cloneBeforeCaching", "url": "YAHOO.util.DataSourceBase.html#property_cloneBeforeCaching", "type": "property"}, {"access": "", "host": "YAHOO.util.XHRDataSource", "name": "connMethodPost", "url": "YAHOO.util.XHRDataSource.html#property_connMethodPost", "type": "property"}, {"access": "", "host": "YAHOO.util.XHRDataSource", "name": "connMgr", "url": "YAHOO.util.XHRDataSource.html#property_connMgr", "type": "property"}, {"access": "", "host": "YAHOO.util.XHRDataSource", "name": "connTimeout", "url": "YAHOO.util.XHRDataSource.html#property_connTimeout", "type": "property"}, {"access": "", "host": "YAHOO.util.XHRDataSource", "name": "connXhrMode", "url": "YAHOO.util.XHRDataSource.html#property_connXhrMode", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "dataErrorEvent", "url": "YAHOO.util.DataSourceBase.html#event_dataErrorEvent", "type": "event"}, {"access": "private", "host": "YAHOO.util.DataSourceBase", "name": "DataSourceBase._cloneObject", "url": "YAHOO.util.DataSourceBase.html#method_DataSourceBase._cloneObject", "type": "method"}, {"access": "private", "host": "YAHOO.util.DataSourceBase", "name": "DataSourceBase._nIndex", "url": "YAHOO.util.DataSourceBase.html#property_DataSourceBase._nIndex", "type": "property"}, {"access": "private", "host": "YAHOO.util.DataSourceBase", "name": "DataSourceBase._nTransactionId", "url": "YAHOO.util.DataSourceBase.html#property_DataSourceBase._nTransactionId", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "DataSourceBase.parseDate", "url": "YAHOO.util.DataSourceBase.html#method_DataSourceBase.parseDate", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "DataSourceBase.parseNumber", "url": "YAHOO.util.DataSourceBase.html#method_DataSourceBase.parseNumber", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "DataSourceBase.parseString", "url": "YAHOO.util.DataSourceBase.html#method_DataSourceBase.parseString", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "DataSource.Parser", "url": "YAHOO.util.DataSourceBase.html#property_DataSource.Parser", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "dataType", "url": "YAHOO.util.DataSourceBase.html#property_dataType", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "doBeforeCallback", "url": "YAHOO.util.DataSourceBase.html#method_doBeforeCallback", "type": "method"}, {"access": "", "host": "YAHOO.util.ScriptNodeDataSource", "name": "doBeforeGetScriptNode", "url": "YAHOO.util.ScriptNodeDataSource.html#method_doBeforeGetScriptNode", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "doBeforeParseData", "url": "YAHOO.util.DataSourceBase.html#method_doBeforeParseData", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "ERROR_DATAINVALID", "url": "YAHOO.util.DataSourceBase.html#property_ERROR_DATAINVALID", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "ERROR_DATANULL", "url": "YAHOO.util.DataSourceBase.html#property_ERROR_DATANULL", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "flushCache", "url": "YAHOO.util.DataSourceBase.html#method_flushCache", "type": "method"}, {"access": "", "host": "YAHOO.util.Number", "name": "format", "url": "YAHOO.util.Number.html#method_format", "type": "method"}, {"access": "", "host": "YAHOO.util.Date", "name": "format", "url": "YAHOO.util.Date.html#method_format", "type": "method"}, {"access": "", "host": "YAHOO.util.ScriptNodeDataSource", "name": "generateRequestCallback", "url": "YAHOO.util.ScriptNodeDataSource.html#method_generateRequestCallback", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "getCachedResponse", "url": "YAHOO.util.DataSourceBase.html#method_getCachedResponse", "type": "method"}, {"access": "private", "host": "YAHOO.util.DataSourceBase", "name": "_getLocationValue", "url": "YAHOO.util.DataSourceBase.html#method__getLocationValue", "type": "method"}, {"access": "", "host": "YAHOO.util.ScriptNodeDataSource", "name": "getUtility", "url": "YAHOO.util.ScriptNodeDataSource.html#property_getUtility", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "handleResponse", "url": "YAHOO.util.DataSourceBase.html#method_handleResponse", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "isCacheHit", "url": "YAHOO.util.DataSourceBase.html#method_isCacheHit", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "issueCallback", "url": "YAHOO.util.DataSourceBase.html#method_issueCallback", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "liveData", "url": "YAHOO.util.DataSourceBase.html#property_liveData", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "makeConnection", "url": "YAHOO.util.DataSourceBase.html#method_makeConnection", "type": "method"}, {"access": "", "host": "YAHOO.util.FunctionDataSource", "name": "makeConnection", "url": "YAHOO.util.FunctionDataSource.html#method_makeConnection", "type": "method"}, {"access": "", "host": "YAHOO.util.ScriptNodeDataSource", "name": "makeConnection", "url": "YAHOO.util.ScriptNodeDataSource.html#method_makeConnection", "type": "method"}, {"access": "", "host": "YAHOO.util.XHRDataSource", "name": "makeConnection", "url": "YAHOO.util.XHRDataSource.html#method_makeConnection", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "maxCacheEntries", "url": "YAHOO.util.DataSourceBase.html#property_maxCacheEntries", "type": "property"}, {"access": "private", "host": "YAHOO.util.ScriptNodeDataSource", "name": "_nId", "url": "YAHOO.util.ScriptNodeDataSource.html#property__nId", "type": "property"}, {"access": "private", "host": "YAHOO.util.ScriptNodeDataSource", "name": "_nPending", "url": "YAHOO.util.ScriptNodeDataSource.html#property__nPending", "type": "property"}, {"access": "", "host": "YAHOO.util.Number", "name": "Number.format._applyFormat", "url": "YAHOO.util.Number.html#method_Number.format._applyFormat", "type": "method"}, {"access": "", "host": "YAHOO.util.Number", "name": "Number.format.defaults", "url": "YAHOO.util.Number.html#property_Number.format.defaults", "type": "property"}, {"access": "private", "host": "YAHOO.util.DataSourceBase", "name": "_oQueue", "url": "YAHOO.util.DataSourceBase.html#property__oQueue", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "parseArrayData", "url": "YAHOO.util.DataSourceBase.html#method_parseArrayData", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "parseData", "url": "YAHOO.util.DataSourceBase.html#method_parseData", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "parseHTMLTableData", "url": "YAHOO.util.DataSourceBase.html#method_parseHTMLTableData", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "parseJSONArgs", "url": "YAHOO.util.DataSourceBase.html#property_parseJSONArgs", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "parseJSONData", "url": "YAHOO.util.DataSourceBase.html#method_parseJSONData", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "parseTextData", "url": "YAHOO.util.DataSourceBase.html#method_parseTextData", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "parseXMLData", "url": "YAHOO.util.DataSourceBase.html#method_parseXMLData", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "parseXMLResult", "url": "YAHOO.util.DataSourceBase.html#method_parseXMLResult", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "requestEvent", "url": "YAHOO.util.DataSourceBase.html#event_requestEvent", "type": "event"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "responseCacheEvent", "url": "YAHOO.util.DataSourceBase.html#event_responseCacheEvent", "type": "event"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "responseEvent", "url": "YAHOO.util.DataSourceBase.html#event_responseEvent", "type": "event"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "responseParseEvent", "url": "YAHOO.util.DataSourceBase.html#event_responseParseEvent", "type": "event"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "responseSchema", "url": "YAHOO.util.DataSourceBase.html#property_responseSchema", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "responseType", "url": "YAHOO.util.DataSourceBase.html#property_responseType", "type": "property"}, {"access": "", "host": "YAHOO.util.FunctionDataSource", "name": "scope", "url": "YAHOO.util.FunctionDataSource.html#property_scope", "type": "property"}, {"access": "", "host": "YAHOO.util.ScriptNodeDataSource", "name": "scriptCallbackParam", "url": "YAHOO.util.ScriptNodeDataSource.html#property_scriptCallbackParam", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "sendRequest", "url": "YAHOO.util.DataSourceBase.html#method_sendRequest", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "setInterval", "url": "YAHOO.util.DataSourceBase.html#method_setInterval", "type": "method"}, {"access": "private", "host": "YAHOO.util.DataSourceBase", "name": "_sName", "url": "YAHOO.util.DataSourceBase.html#property__sName", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "toString", "url": "YAHOO.util.DataSourceBase.html#method_toString", "type": "method"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "TYPE_HTMLTABLE", "url": "YAHOO.util.DataSourceBase.html#property_TYPE_HTMLTABLE", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "TYPE_JSARRAY", "url": "YAHOO.util.DataSourceBase.html#property_TYPE_JSARRAY", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "TYPE_JSFUNCTION", "url": "YAHOO.util.DataSourceBase.html#property_TYPE_JSFUNCTION", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "TYPE_JSON", "url": "YAHOO.util.DataSourceBase.html#property_TYPE_JSON", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "TYPE_LOCAL", "url": "YAHOO.util.DataSourceBase.html#property_TYPE_LOCAL", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "TYPE_SCRIPTNODE", "url": "YAHOO.util.DataSourceBase.html#property_TYPE_SCRIPTNODE", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "TYPE_TEXT", "url": "YAHOO.util.DataSourceBase.html#property_TYPE_TEXT", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "TYPE_UNKNOWN", "url": "YAHOO.util.DataSourceBase.html#property_TYPE_UNKNOWN", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "TYPE_XHR", "url": "YAHOO.util.DataSourceBase.html#property_TYPE_XHR", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "TYPE_XML", "url": "YAHOO.util.DataSourceBase.html#property_TYPE_XML", "type": "property"}, {"access": "", "host": "YAHOO.util.DataSourceBase", "name": "useXPath", "url": "YAHOO.util.DataSourceBase.html#property_useXPath", "type": "property"}, {"access": "private", "host": "YAHOO.util.XHRDataSource", "name": "_xhrCallback", "url": "YAHOO.util.XHRDataSource.html#property__xhrCallback", "type": "property"}, {"access": "private", "host": "YAHOO.util.XHRDataSource", "name": "_xhrFailure", "url": "YAHOO.util.XHRDataSource.html#method__xhrFailure", "type": "method"}, {"access": "private", "host": "YAHOO.util.XHRDataSource", "name": "_xhrSuccess", "url": "YAHOO.util.XHRDataSource.html#method__xhrSuccess", "type": "method"}];
</script>
</body>
</html>
